home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cocktail / puma.lha / puma / m2c / Semantics.c < prev    next >
C/C++ Source or Header  |  1992-09-25  |  68KB  |  2,522 lines

  1. #include "SYSTEM_.h"
  2.  
  3. #ifndef DEFINITION_System
  4. #include "System.h"
  5. #endif
  6.  
  7. #ifndef DEFINITION_IO
  8. #include "IO.h"
  9. #endif
  10.  
  11. #ifndef DEFINITION_Tree
  12. #include "Tree.h"
  13. #endif
  14.  
  15. #ifndef DEFINITION_General
  16. #include "General.h"
  17. #endif
  18.  
  19. #ifndef DEFINITION_IO
  20. #include "IO.h"
  21. #endif
  22.  
  23. #ifndef DEFINITION_DynArray
  24. #include "DynArray.h"
  25. #endif
  26.  
  27. #ifndef DEFINITION_Strings
  28. #include "Strings.h"
  29. #endif
  30.  
  31. #ifndef DEFINITION_Idents
  32. #include "Idents.h"
  33. #endif
  34.  
  35. #ifndef DEFINITION_Texts
  36. #include "Texts.h"
  37. #endif
  38.  
  39. #ifndef DEFINITION_Scanner
  40. #include "Scanner.h"
  41. #endif
  42.  
  43. #ifndef DEFINITION_Positions
  44. #include "Positions.h"
  45. #endif
  46.  
  47. #ifndef DEFINITION_Sets
  48. #include "Sets.h"
  49. #endif
  50.  
  51. #ifndef DEFINITION_Tree
  52. #include "Tree.h"
  53. #endif
  54.  
  55. #ifndef DEFINITION_Semantics
  56. #include "Semantics.h"
  57. #endif
  58.  
  59. SHORTCARD Semantics_TypeCount;
  60. Sets_tSet Semantics_TypeNames, Semantics_UserTypes;
  61. IO_tFile Semantics_yyf;
  62. PROC Semantics_Exit;
  63.  
  64. static Sets_tSet ExternNames, LocExternNames, ActTypes, ActNames, UserNames, LabelNames, ParamNames, RoutineNames;
  65. static Tree_tTree dFormals, Parameters, Decls, Args, InFormals, OutFormals, ReturnFormal, Node, Var, TreeName, ActTree, ActClass;
  66. static INTEGER RuleCount, VarCount;
  67. static Idents_tIdent ProcName, ParamName;
  68. static BOOLEAN HasLocals, IsFunction, IsOutput, Mode, Success;
  69. static Strings_tString String, String1;
  70. static CARDINAL i;
  71. static Tree_tTree nNoFormal;
  72. static Tree_tTree IdentifyClass ARGS((Tree_tTree t, Idents_tIdent Ident));
  73. static Tree_tTree IdentifyTree ARGS((Idents_tIdent i));
  74. static Tree_tTree IdentifyProc ARGS((Idents_tIdent i));
  75. static Tree_tTree IdentifyClass2 ARGS((Idents_tIdent i, Tree_tTree *TreeName));
  76. static void MakeTypes ARGS((INTEGER Index, Tree_tTree Classes, Sets_tSet *Types));
  77. static void CheckSubtype ARGS((Tree_tTree t1, Tree_tTree t2, Positions_tPosition Pos));
  78. static void CheckType ARGS((Tree_tTree t1, Tree_tTree t2, Positions_tPosition Pos));
  79. static Tree_tTree TransformPattern ARGS((Tree_tTree t));
  80. static Tree_tTree TransformExpr ARGS((Tree_tTree t));
  81. static Tree_tTree TransformStmt ARGS((Tree_tTree t));
  82. static Tree_tTree TransformName ARGS((Tree_tTree t, Tree_tTree Formals));
  83. struct S_3 {
  84.     Tree_tTree A[50000 + 1];
  85. };
  86. static INTEGER Lookup ARGS((Idents_tIdent Ident, Tree_tTree Formals));
  87. static void CheckExprList ARGS((Tree_tTree t, Tree_tTree Formals));
  88. static void CheckInParams ARGS((Tree_tTree t, Tree_tTree Formals));
  89. static void CheckCallExprs ARGS((Tree_tTree t, Tree_tTree Formals));
  90. static void CheckExprVar ARGS((Tree_tTree t, Tree_tTree Formals));
  91. static void CheckExpr ARGS((Tree_tTree t, Tree_tTree Formals));
  92. static void CheckExpr2 ARGS((Tree_tTree t));
  93. static void CheckPatternList ARGS((Tree_tTree t, Tree_tTree Formals));
  94. static void CheckSubPatterns ARGS((Tree_tTree t, Tree_tTree Formals, Tree_tTree Path));
  95. static void CheckCallPatterns ARGS((Tree_tTree t, Tree_tTree Formals));
  96. static void CheckPattern ARGS((Tree_tTree t, Tree_tTree Formals, Tree_tTree Path));
  97. static Idents_tIdent MakeVar ARGS(());
  98. static Tree_tTree MakeTempos ARGS((Tree_tTree Formals));
  99. static void yyAbort ARGS((CHAR yyFunction[], LONGCARD ));
  100. static BOOLEAN yyIsEqual ARGS((BYTE yya[], LONGCARD , BYTE yyb[], LONGCARD ));
  101. struct S_4 {
  102.     union {
  103.         char dummy;
  104.     } U_1;
  105. };
  106. static void CollectExtern ARGS((Tree_tTree t, Sets_tSet *Names));
  107. struct S_5 {
  108.     union {
  109.         char dummy;
  110.     } U_1;
  111. };
  112. static void ProcFormals ARGS((Tree_tTree t));
  113. struct S_6 {
  114.     union {
  115.         char dummy;
  116.     } U_1;
  117. };
  118. static void ClassFormals ARGS((Tree_tTree t));
  119. struct S_7 {
  120.     union {
  121.         char dummy;
  122.     } U_1;
  123. };
  124. static void CountClasses ARGS((Tree_tTree t));
  125. struct S_8 {
  126.     union {
  127.         char dummy;
  128.     } U_1;
  129. };
  130. static void ClassTypes ARGS((Tree_tTree t));
  131. struct S_9 {
  132.     union {
  133.         char dummy;
  134.     } U_1;
  135. };
  136. static void Check ARGS((Tree_tTree t));
  137. struct S_10 {
  138.     union {
  139.         char dummy;
  140.     } U_1;
  141. };
  142. static void CheckTargetCode ARGS((Tree_tTree t));
  143. struct S_11 {
  144.     union {
  145.         char dummy;
  146.     } U_1;
  147. };
  148. struct S_12 {
  149.     union {
  150.         struct {
  151.             struct S_13 {
  152.                 Strings_tString String1;
  153.                 Strings_tString String2;
  154.                 Idents_tIdent i;
  155.             } yyR2;
  156.         } V_1;
  157.     } U_1;
  158. };
  159. static BOOLEAN HasReject ARGS((Tree_tTree yyP1));
  160. struct S_14 {
  161.     union {
  162.         char dummy;
  163.     } U_1;
  164. };
  165. static void yyExit ARGS(());
  166.  
  167.  
  168. static Tree_tTree IdentifyClass
  169. # ifdef __STDC__
  170. (Tree_tTree t, Idents_tIdent Ident)
  171. # else
  172. (t, Ident)
  173. Tree_tTree t;
  174. Idents_tIdent Ident;
  175. # endif
  176. {
  177.   Tree_tTree class;
  178.  
  179.   while (t->U_1.V_1.Kind == Tree_Class) {
  180.     {
  181.       register Tree_yClass *W_1 = &t->U_1.V_5.Class;
  182.  
  183.       if (W_1->Name == Ident) {
  184.         return t;
  185.       }
  186.       class = IdentifyClass(W_1->Extensions, Ident);
  187.       if (class != Tree_NoTree) {
  188.         return class;
  189.       }
  190.       t = W_1->Next;
  191.     }
  192.   }
  193.   return Tree_NoTree;
  194. }
  195.  
  196. static Tree_tTree IdentifyTree
  197. # ifdef __STDC__
  198. (Idents_tIdent i)
  199. # else
  200. (i)
  201. Idents_tIdent i;
  202. # endif
  203. {
  204.   Tree_tTree Node;
  205.  
  206.   Node = Tree_TreeRoot->U_1.V_26.Spec.TreeNames;
  207.   while (Node->U_1.V_1.Kind == Tree_TreeName) {
  208.     if (Node->U_1.V_29.TreeName.Name == i) {
  209.       return Node;
  210.     }
  211.     Node = Node->U_1.V_29.TreeName.Next;
  212.   }
  213.   return Tree_NoTree;
  214. }
  215.  
  216. static Tree_tTree IdentifyProc
  217. # ifdef __STDC__
  218. (Idents_tIdent i)
  219. # else
  220. (i)
  221. Idents_tIdent i;
  222. # endif
  223. {
  224.   Tree_tTree Node;
  225.  
  226.   Node = Tree_TreeRoot->U_1.V_26.Spec.Routines;
  227.   while (Node->U_1.V_1.Kind != Tree_NoRoutine) {
  228.     if (Node->U_1.V_32.Routine.Name == i) {
  229.       return Node;
  230.     }
  231.     Node = Node->U_1.V_32.Routine.Next;
  232.   }
  233.   return Tree_NoTree;
  234. }
  235.  
  236. Tree_tTree Semantics_IdentifyVar
  237. # ifdef __STDC__
  238. (Tree_tTree Node, Idents_tIdent i)
  239. # else
  240. (Node, i)
  241. Tree_tTree Node;
  242. Idents_tIdent i;
  243. # endif
  244. {
  245.   while (Node->U_1.V_1.Kind != Tree_NoFormal) {
  246.     if (Node->U_1.V_86.Formal.Name == i) {
  247.       return Node;
  248.     }
  249.     Node = Node->U_1.V_86.Formal.Next;
  250.   }
  251.   return Tree_NoTree;
  252. }
  253.  
  254. static Tree_tTree IdentifyClass2
  255. # ifdef __STDC__
  256. (Idents_tIdent i, Tree_tTree *TreeName)
  257. # else
  258. (i, TreeName)
  259. Idents_tIdent i;
  260. Tree_tTree *TreeName;
  261. # endif
  262. {
  263.   Tree_tTree Class;
  264.  
  265.   *TreeName = Tree_TreeRoot->U_1.V_26.Spec.TreeNames;
  266.   while ((*TreeName)->U_1.V_1.Kind == Tree_TreeName) {
  267.     Class = IdentifyClass((*TreeName)->U_1.V_29.TreeName.Classes, i);
  268.     if (Class != Tree_NoTree) {
  269.       return Class;
  270.     }
  271.     *TreeName = (*TreeName)->U_1.V_29.TreeName.Next;
  272.   }
  273.   *TreeName = Tree_NoTree;
  274.   return Tree_NoTree;
  275. }
  276.  
  277. Tree_tTree Semantics_LookupClass
  278. # ifdef __STDC__
  279. (Tree_tTree Classes, CARDINAL i)
  280. # else
  281. (Classes, i)
  282. Tree_tTree Classes;
  283. CARDINAL i;
  284. # endif
  285. {
  286.   Tree_tTree Class;
  287.  
  288.   if (Classes->U_1.V_1.Kind == Tree_NoClass) {
  289.     return Tree_NoTree;
  290.   }
  291.   {
  292.     register Tree_yClass *W_2 = &Classes->U_1.V_5.Class;
  293.  
  294.     if (W_2->Index == i) {
  295.       return Classes;
  296.     }
  297.     Class = Semantics_LookupClass(W_2->Extensions, i);
  298.     if (Class != Tree_NoTree) {
  299.       return Class;
  300.     }
  301.     return Semantics_LookupClass(W_2->Next, i);
  302.   }
  303. }
  304.  
  305. static void MakeTypes
  306. # ifdef __STDC__
  307. (INTEGER Index, Tree_tTree Classes, Sets_tSet *Types)
  308. # else
  309. (Index, Classes, Types)
  310. INTEGER Index;
  311. Tree_tTree Classes;
  312. Sets_tSet *Types;
  313. # endif
  314. {
  315.   ActTypes = *Types;
  316.   Tree_ForallClasses(Classes, (Tree_ProcOfT)ProcFormals);
  317.   Sets_Include(&ActTypes, (LONGCARD)Index);
  318.   *Types = ActTypes;
  319. }
  320.  
  321. static void CheckSubtype
  322. # ifdef __STDC__
  323. (Tree_tTree t1, Tree_tTree t2, Positions_tPosition Pos)
  324. # else
  325. (t1, t2, Pos)
  326. Tree_tTree t1, t2;
  327. Positions_tPosition Pos;
  328. # endif
  329. {
  330.   if (t1->U_1.V_1.Kind == Tree_NodeTypes) {
  331.     if (t2->U_1.V_1.Kind == Tree_UserType) {
  332.       Scanner_Warning((STRING)"tree-type required", 18L, Pos);
  333.     } else if (t2->U_1.V_89.NodeTypes.TreeName != t1->U_1.V_89.NodeTypes.TreeName) {
  334.       Scanner_Error((STRING)"incompatible tree types", 23L, Pos);
  335.     } else if (!Sets_IsSubset(t2->U_1.V_89.NodeTypes.Types, t1->U_1.V_89.NodeTypes.Types)) {
  336.       Scanner_Error((STRING)"subtype required", 16L, Pos);
  337.     }
  338.   } else if (t1->U_1.V_1.Kind == Tree_UserType) {
  339.     if (t2->U_1.V_1.Kind == Tree_NodeTypes) {
  340.       Scanner_Warning((STRING)"user-type required", 18L, Pos);
  341.     } else if (t2->U_1.V_90.UserType.Type != t1->U_1.V_90.UserType.Type) {
  342.       Scanner_Warning((STRING)"incompatible types", 18L, Pos);
  343.     }
  344.   }
  345. }
  346.  
  347. static void CheckType
  348. # ifdef __STDC__
  349. (Tree_tTree t1, Tree_tTree t2, Positions_tPosition Pos)
  350. # else
  351. (t1, t2, Pos)
  352. Tree_tTree t1, t2;
  353. Positions_tPosition Pos;
  354. # endif
  355. {
  356.   Sets_tSet t;
  357.  
  358.   if (t1->U_1.V_1.Kind == Tree_NodeTypes) {
  359.     if (t2->U_1.V_1.Kind == Tree_UserType) {
  360.       Scanner_Warning((STRING)"tree-type required", 18L, Pos);
  361.     } else if (t2->U_1.V_89.NodeTypes.TreeName != t1->U_1.V_89.NodeTypes.TreeName) {
  362.       Scanner_Error((STRING)"incompatible tree types", 23L, Pos);
  363.     } else {
  364.       Sets_MakeSet(&t, (LONGCARD)t1->U_1.V_89.NodeTypes.TreeName->U_1.V_29.TreeName.ClassCount);
  365.       Sets_Assign(&t, t1->U_1.V_89.NodeTypes.Types);
  366.       Sets_Intersection(&t, t2->U_1.V_89.NodeTypes.Types);
  367.       if (Sets_IsEmpty(t)) {
  368.         Scanner_Warning((STRING)"incompatible node types", 23L, Pos);
  369.       }
  370.       Sets_ReleaseSet(&t);
  371.     }
  372.   } else if (t1->U_1.V_1.Kind == Tree_UserType) {
  373.     if (t2->U_1.V_1.Kind == Tree_NodeTypes) {
  374.       Scanner_Warning((STRING)"user-type required", 18L, Pos);
  375.     } else if (t2->U_1.V_90.UserType.Type != t1->U_1.V_90.UserType.Type) {
  376.       Scanner_Warning((STRING)"incompatible types", 18L, Pos);
  377.     }
  378.   }
  379. }
  380.  
  381. static Tree_tTree TransformPattern
  382. # ifdef __STDC__
  383. (Tree_tTree t)
  384. # else
  385. (t)
  386. Tree_tTree t;
  387. # endif
  388. {
  389.   Tree_tTree TreeName, s, object;
  390.  
  391.   switch (t->U_1.V_1.Kind) {
  392.   case Tree_NoExpr:;
  393.     return Tree_mNoPattern(t->U_1.V_57.NoExpr.Pos);
  394.     break;
  395.   case Tree_OneExpr:;
  396.     {
  397.       register Tree_yOneExpr *W_3 = &t->U_1.V_58.OneExpr;
  398.  
  399.       return Tree_mOnePattern(TransformPattern(W_3->Expr), TransformPattern(W_3->Next));
  400.     }
  401.     break;
  402.   case Tree_NamedExpr:;
  403.     {
  404.       register Tree_yNamedExpr *W_4 = &t->U_1.V_59.NamedExpr;
  405.  
  406.       Scanner_Error((STRING)"pattern name illegal", 20L, W_4->Expr->U_1.V_60.Expr.Pos);
  407.       return Tree_mOnePattern(TransformPattern(W_4->Expr), TransformPattern(W_4->Next));
  408.     }
  409.     break;
  410.   case Tree_Compose:;
  411.     {
  412.       register Tree_yCompose *W_5 = &t->U_1.V_61.Compose;
  413.  
  414.       if (W_5->Expr->U_1.V_1.Kind == Tree_VarUse) {
  415.         W_5->Object = IdentifyClass2(W_5->Expr->U_1.V_62.VarUse.Name, &TreeName);
  416.         if (W_5->Object == Tree_NoTree) {
  417.           W_5->Object = IdentifyProc(W_5->Expr->U_1.V_62.VarUse.Name);
  418.         }
  419.       } else if (W_5->Expr->U_1.V_1.Kind == Tree_Binary && W_5->Expr->U_1.V_66.Binary.Lop->U_1.V_1.Kind == Tree_VarUse && W_5->Expr->U_1.V_66.Binary.Rop->U_1.V_1.Kind == Tree_VarUse) {
  420.         W_5->Object = IdentifyTree(W_5->Expr->U_1.V_66.Binary.Lop->U_1.V_62.VarUse.Name);
  421.         if (W_5->Object != Tree_NoTree) {
  422.           W_5->Object = IdentifyClass(W_5->Object->U_1.V_29.TreeName.Classes, W_5->Expr->U_1.V_66.Binary.Rop->U_1.V_62.VarUse.Name);
  423.         }
  424.       } else {
  425.         W_5->Object = Tree_NoTree;
  426.       }
  427.       W_5->Expr = TransformExpr(W_5->Expr);
  428.       if (W_5->Object != Tree_NoTree) {
  429.         if (W_5->Object->U_1.V_1.Kind == Tree_Class) {
  430.           W_5->Exprs = TransformName(W_5->Exprs, W_5->Object->U_1.V_5.Class.Formals);
  431.           s = Tree_mDecompose(W_5->Pos, W_5->Selector, W_5->Expr, TransformPattern(W_5->Exprs), W_5->Widen);
  432.           s->U_1.V_50.Decompose.Object = W_5->Object;
  433.           return s;
  434.         } else {
  435.           s = Tree_mCall(W_5->Pos, W_5->Expr, TransformExpr(W_5->Exprs), Tree_mNoPattern(W_5->Pos));
  436.           s->U_1.V_65.Call.Object = W_5->Object;
  437.           return Tree_mValue(W_5->Pos, s);
  438.         }
  439.       } else {
  440.         s = Tree_mCall(W_5->Pos, W_5->Expr, TransformExpr(W_5->Exprs), Tree_mNoExpr(W_5->Pos));
  441.         s->U_1.V_65.Call.Object = W_5->Object;
  442.         return Tree_mValue(W_5->Pos, s);
  443.       }
  444.     }
  445.     break;
  446.   case Tree_VarUse:;
  447.     {
  448.       register Tree_yVarUse *W_6 = &t->U_1.V_62.VarUse;
  449.  
  450.       W_6->Object = IdentifyClass2(W_6->Name, &TreeName);
  451.       if (W_6->Object != Tree_NoTree && Sets_IsElement(ORD('p'), &Tree_Options)) {
  452.         s = Tree_mDecompose(W_6->Pos, Idents_NoIdent, t, Tree_mOnePattern(Tree_mDontCare(W_6->Pos), Tree_mNoPattern(W_6->Pos)), FALSE);
  453.         s->U_1.V_50.Decompose.Object = W_6->Object;
  454.         return s;
  455.       } else {
  456.         return Tree_mVarDef(W_6->Pos, W_6->Name);
  457.       }
  458.     }
  459.     break;
  460.   case Tree_Nil:;
  461.     return Tree_mNilTest(t->U_1.V_64.Nil.Pos, t->U_1.V_64.Nil.Selector);
  462.     break;
  463.   case Tree_DontCare1:;
  464.   case Tree_DontCare:;
  465.     return t;
  466.     break;
  467.   case Tree_Binary:;
  468.     {
  469.       register Tree_yBinary *W_7 = &t->U_1.V_66.Binary;
  470.  
  471.       if (Sets_IsElement(ORD('p'), &Tree_Options) && W_7->Operator == Idents_MakeIdent(&String1) && W_7->Lop->U_1.V_1.Kind == Tree_VarUse && W_7->Rop->U_1.V_1.Kind == Tree_VarUse) {
  472.         object = IdentifyTree(W_7->Lop->U_1.V_62.VarUse.Name);
  473.         if (object != Tree_NoTree) {
  474.           object = IdentifyClass(object->U_1.V_29.TreeName.Classes, W_7->Rop->U_1.V_62.VarUse.Name);
  475.           if (object != Tree_NoTree) {
  476.             s = Tree_mDecompose(W_7->Pos, Idents_NoIdent, t, Tree_mOnePattern(Tree_mDontCare(W_7->Pos), Tree_mNoPattern(W_7->Pos)), FALSE);
  477.             s->U_1.V_50.Decompose.Object = object;
  478.             return s;
  479.           }
  480.         }
  481.       }
  482.       return Tree_mValue(W_7->Pos, TransformExpr(t));
  483.     }
  484.     break;
  485.   case Tree_Call:;
  486.   case Tree_PreOperator:;
  487.   case Tree_PostOperator:;
  488.   case Tree_Index:;
  489.   case Tree_Parents:;
  490.   case Tree_TargetExpr:;
  491.   case Tree_StringExpr:;
  492.   case Tree_AttrDesc:;
  493.     return Tree_mValue(t->U_1.V_60.Expr.Pos, TransformExpr(t));
  494.     break;
  495.   }
  496. }
  497.  
  498. static Tree_tTree TransformExpr
  499. # ifdef __STDC__
  500. (Tree_tTree t)
  501. # else
  502. (t)
  503. Tree_tTree t;
  504. # endif
  505. {
  506.   Tree_tTree TreeName, s, object;
  507.  
  508.   switch (t->U_1.V_1.Kind) {
  509.   case Tree_NoExpr:;
  510.     break;
  511.   case Tree_OneExpr:;
  512.     {
  513.       register Tree_yOneExpr *W_8 = &t->U_1.V_58.OneExpr;
  514.  
  515.       W_8->Expr = TransformExpr(W_8->Expr);
  516.       W_8->Next = TransformExpr(W_8->Next);
  517.     }
  518.     break;
  519.   case Tree_NamedExpr:;
  520.     {
  521.       register Tree_yNamedExpr *W_9 = &t->U_1.V_59.NamedExpr;
  522.  
  523.       Scanner_Error((STRING)"argument name illegal", 21L, t->U_1.V_59.NamedExpr.Expr->U_1.V_60.Expr.Pos);
  524.       return Tree_mOneExpr(TransformExpr(W_9->Expr), TransformExpr(W_9->Next));
  525.     }
  526.     break;
  527.   case Tree_Compose:;
  528.     {
  529.       register Tree_yCompose *W_10 = &t->U_1.V_61.Compose;
  530.  
  531.       if (W_10->Expr->U_1.V_1.Kind == Tree_VarUse) {
  532.         W_10->Object = IdentifyClass2(W_10->Expr->U_1.V_62.VarUse.Name, &TreeName);
  533.         if (W_10->Object == Tree_NoTree) {
  534.           W_10->Object = IdentifyProc(W_10->Expr->U_1.V_62.VarUse.Name);
  535.         }
  536.       } else if (W_10->Expr->U_1.V_1.Kind == Tree_Binary && W_10->Expr->U_1.V_66.Binary.Lop->U_1.V_1.Kind == Tree_VarUse && W_10->Expr->U_1.V_66.Binary.Rop->U_1.V_1.Kind == Tree_VarUse) {
  537.         W_10->Object = IdentifyTree(W_10->Expr->U_1.V_66.Binary.Lop->U_1.V_62.VarUse.Name);
  538.         if (W_10->Object != Tree_NoTree) {
  539.           W_10->Object = IdentifyClass(W_10->Object->U_1.V_29.TreeName.Classes, W_10->Expr->U_1.V_66.Binary.Rop->U_1.V_62.VarUse.Name);
  540.         }
  541.       } else {
  542.         W_10->Object = Tree_NoTree;
  543.       }
  544.       W_10->Expr = TransformExpr(W_10->Expr);
  545.       if (W_10->Object != Tree_NoTree) {
  546.         if (W_10->Object->U_1.V_1.Kind == Tree_Class) {
  547.           W_10->Exprs = TransformName(W_10->Exprs, W_10->Object->U_1.V_5.Class.Formals);
  548.           W_10->Exprs = TransformExpr(W_10->Exprs);
  549.           return t;
  550.         } else {
  551.           s = Tree_mCall(W_10->Pos, W_10->Expr, TransformExpr(W_10->Exprs), Tree_mNoPattern(W_10->Pos));
  552.           s->U_1.V_65.Call.Object = W_10->Object;
  553.           return s;
  554.         }
  555.       } else {
  556.         s = Tree_mCall(W_10->Pos, W_10->Expr, TransformExpr(W_10->Exprs), Tree_mNoExpr(W_10->Pos));
  557.         s->U_1.V_65.Call.Object = W_10->Object;
  558.         return s;
  559.       }
  560.     }
  561.     break;
  562.   case Tree_VarUse:;
  563.     {
  564.       register Tree_yVarUse *W_11 = &t->U_1.V_62.VarUse;
  565.  
  566.       W_11->Object = IdentifyClass2(W_11->Name, &TreeName);
  567.       if (W_11->Object != Tree_NoTree && Sets_IsElement(ORD('p'), &Tree_Options)) {
  568.         s = Tree_mCompose(W_11->Pos, Idents_NoIdent, t, Tree_mOneExpr(Tree_mDontCare(W_11->Pos), Tree_mNoExpr(W_11->Pos)), FALSE);
  569.         s->U_1.V_61.Compose.Object = W_11->Object;
  570.         return s;
  571.       } else {
  572.         W_11->Object = Tree_NoTree;
  573.         return t;
  574.       }
  575.     }
  576.     break;
  577.   case Tree_Nil:;
  578.     break;
  579.   case Tree_DontCare1:;
  580.     break;
  581.   case Tree_DontCare:;
  582.     break;
  583.   case Tree_Call:;
  584.     {
  585.       register Tree_yCall *W_12 = &t->U_1.V_65.Call;
  586.  
  587.       if (W_12->Expr->U_1.V_1.Kind == Tree_VarUse) {
  588.         W_12->Object = IdentifyProc(W_12->Expr->U_1.V_62.VarUse.Name);
  589.       } else {
  590.         W_12->Object = Tree_NoTree;
  591.       }
  592.       W_12->Expr = TransformExpr(W_12->Expr);
  593.       W_12->Exprs = TransformExpr(W_12->Exprs);
  594.       if (W_12->Object != Tree_NoTree) {
  595.         W_12->Patterns = TransformPattern(W_12->Patterns);
  596.       } else {
  597.         W_12->Patterns = TransformExpr(W_12->Patterns);
  598.       }
  599.     }
  600.     break;
  601.   case Tree_Binary:;
  602.     {
  603.       register Tree_yBinary *W_13 = &t->U_1.V_66.Binary;
  604.  
  605.       if (Sets_IsElement(ORD('p'), &Tree_Options) && W_13->Lop->U_1.V_1.Kind == Tree_VarUse && W_13->Rop->U_1.V_1.Kind == Tree_VarUse) {
  606.         object = IdentifyTree(W_13->Lop->U_1.V_62.VarUse.Name);
  607.         if (object != Tree_NoTree) {
  608.           object = IdentifyClass(object->U_1.V_29.TreeName.Classes, W_13->Rop->U_1.V_62.VarUse.Name);
  609.           if (object != Tree_NoTree) {
  610.             s = Tree_mCompose(W_13->Pos, Idents_NoIdent, t, Tree_mOneExpr(Tree_mDontCare(W_13->Pos), Tree_mNoExpr(W_13->Pos)), FALSE);
  611.             s->U_1.V_61.Compose.Object = object;
  612.             return s;
  613.           }
  614.         }
  615.       }
  616.       W_13->Lop = TransformExpr(W_13->Lop);
  617.       W_13->Rop = TransformExpr(W_13->Rop);
  618.     }
  619.     break;
  620.   case Tree_PreOperator:;
  621.   case Tree_PostOperator:;
  622.     {
  623.       register Tree_yPreOperator *W_14 = &t->U_1.V_67.PreOperator;
  624.  
  625.       W_14->Expr = TransformExpr(W_14->Expr);
  626.     }
  627.     break;
  628.   case Tree_Index:;
  629.     {
  630.       register Tree_yIndex *W_15 = &t->U_1.V_69.Index;
  631.  
  632.       W_15->Expr = TransformExpr(W_15->Expr);
  633.       W_15->Exprs = TransformExpr(W_15->Exprs);
  634.     }
  635.     break;
  636.   case Tree_Parents:;
  637.     {
  638.       register Tree_yParents *W_16 = &t->U_1.V_70.Parents;
  639.  
  640.       W_16->Expr = TransformExpr(W_16->Expr);
  641.     }
  642.     break;
  643.   case Tree_TargetExpr:;
  644.     break;
  645.   case Tree_StringExpr:;
  646.     break;
  647.   case Tree_AttrDesc:;
  648.     break;
  649.   }
  650.   return t;
  651. }
  652.  
  653. static Tree_tTree TransformStmt
  654. # ifdef __STDC__
  655. (Tree_tTree t)
  656. # else
  657. (t)
  658. Tree_tTree t;
  659. # endif
  660. {
  661.   switch (t->U_1.V_1.Kind) {
  662.   case Tree_NoStatement:;
  663.     return t;
  664.     break;
  665.   case Tree_ProcCall:;
  666.     {
  667.       register Tree_yProcCall *W_17 = &t->U_1.V_76.ProcCall;
  668.  
  669.       W_17->Call = TransformExpr(W_17->Call);
  670.       if (W_17->Call->U_1.V_1.Kind == Tree_Call) {
  671.         {
  672.           register Tree_yCall *W_18 = &W_17->Call->U_1.V_65.Call;
  673.  
  674.           if (W_18->Object != Tree_NoTree && (W_18->Object->U_1.V_1.Kind == Tree_Predicate || W_18->Object->U_1.V_1.Kind == Tree_Function)) {
  675.             t->U_1.V_1.Kind = Tree_Condition;
  676.           }
  677.         }
  678.       } else if (W_17->Call->U_1.V_1.Kind == Tree_StringExpr) {
  679.         t = Tree_mWriteStr(W_17->Pos, W_17->Next, W_17->Call->U_1.V_72.StringExpr.String);
  680.       } else {
  681.         t->U_1.V_1.Kind = Tree_Condition;
  682.       }
  683.     }
  684.     break;
  685.   case Tree_Assignment:;
  686.     {
  687.       register Tree_yAssignment *W_19 = &t->U_1.V_78.Assignment;
  688.  
  689.       W_19->Adr = TransformExpr(W_19->Adr);
  690.       W_19->Expr = TransformExpr(W_19->Expr);
  691.     }
  692.     break;
  693.   case Tree_Reject:;
  694.     break;
  695.   case Tree_Fail:;
  696.     break;
  697.   case Tree_TargetStmt:;
  698.     break;
  699.   case Tree_Nl:;
  700.     break;
  701.   case Tree_WriteStr:;
  702.     break;
  703.   }
  704.   t->U_1.V_75.Statement.Next = TransformStmt(t->U_1.V_75.Statement.Next);
  705.   return t;
  706. }
  707.  
  708. static INTEGER Lookup
  709. # ifdef __STDC__
  710. (Idents_tIdent Ident, Tree_tTree Formals)
  711. # else
  712. (Ident, Formals)
  713. Idents_tIdent Ident;
  714. Tree_tTree Formals;
  715. # endif
  716. {
  717.   INTEGER i;
  718.  
  719.   i = 0;
  720.   while (Formals->U_1.V_1.Kind == Tree_Formal) {
  721.     INC(i);
  722.     if (Formals->U_1.V_86.Formal.Name == Ident) {
  723.       return i;
  724.     }
  725.     Formals = Formals->U_1.V_86.Formal.Next;
  726.   }
  727.   return 0;
  728. }
  729.  
  730. static Tree_tTree TransformName
  731. # ifdef __STDC__
  732. (Tree_tTree t, Tree_tTree Formals)
  733. # else
  734. (t, Formals)
  735. Tree_tTree t, Formals;
  736. # endif
  737. {
  738.   Tree_tTree Exprs;
  739.   Tree_tTree *Last;
  740.   INTEGER n, i, Minimum, Maximum;
  741.   LONGINT PatternsSize;
  742.   struct S_3 *PatternsPtr;
  743.  
  744.   Exprs = t;
  745.   while (Exprs->U_1.V_1.Kind == Tree_OneExpr) {
  746.     Exprs = Exprs->U_1.V_58.OneExpr.Next;
  747.   }
  748.   if (Exprs->U_1.V_1.Kind == Tree_NoExpr) {
  749.     return t;
  750.   }
  751.   n = 0;
  752.   Exprs = Formals;
  753.   while (Exprs->U_1.V_1.Kind == Tree_Formal) {
  754.     INC(n);
  755.     Exprs = Exprs->U_1.V_86.Formal.Next;
  756.   }
  757.   PatternsSize = n + 1;
  758.   DynArray_MakeArray((ADDRESS *)&PatternsPtr, &PatternsSize, (LONGINT)sizeof(Tree_tTree));
  759.   {
  760.     LONGINT B_1 = 1, B_2 = n;
  761.  
  762.     if (B_1 <= B_2)
  763.       for (i = B_1;; i += 1) {
  764.         PatternsPtr->A[i] = Tree_NoTree;
  765.         if (i >= B_2) break;
  766.       }
  767.   }
  768.   Last = (Tree_tTree *)ADR(t);
  769.   Exprs = t;
  770.   i = 0;
  771.   while (Exprs->U_1.V_1.Kind == Tree_OneExpr) {
  772.     INC(i);
  773.     PatternsPtr->A[i] = Exprs->U_1.V_58.OneExpr.Expr;
  774.     Last = (Tree_tTree *)ADR(Exprs->U_1.V_58.OneExpr.Next);
  775.     Exprs = Exprs->U_1.V_58.OneExpr.Next;
  776.   }
  777.   Minimum = i + 1;
  778.   Maximum = i;
  779.   while (Exprs->U_1.V_1.Kind == Tree_NamedExpr) {
  780.     i = Lookup(Exprs->U_1.V_59.NamedExpr.Name, Formals);
  781.     if (i == 0) {
  782.       Scanner_Error((STRING)"identifier not declared", 23L, Exprs->U_1.V_59.NamedExpr.Expr->U_1.V_60.Expr.Pos);
  783.     } else if (PatternsPtr->A[i] != Tree_NoTree) {
  784.       Scanner_Error((STRING)"pattern or argument multiply supplied", 37L, Exprs->U_1.V_59.NamedExpr.Expr->U_1.V_60.Expr.Pos);
  785.     } else {
  786.       PatternsPtr->A[i] = Exprs->U_1.V_59.NamedExpr.Expr;
  787.     }
  788.     Maximum = General_Max(Maximum, i);
  789.     Exprs = Exprs->U_1.V_59.NamedExpr.Next;
  790.   }
  791.   Exprs = Tree_mOneExpr(Tree_mDontCare(Positions_NoPosition), Tree_mNoExpr(Positions_NoPosition));
  792.   {
  793.     LONGINT B_3 = Maximum, B_4 = Minimum;
  794.  
  795.     if (B_3 >= B_4)
  796.       for (i = B_3;; i += -1) {
  797.         if (PatternsPtr->A[i] == Tree_NoTree) {
  798.           Exprs = Tree_mOneExpr(Tree_mDontCare1(Positions_NoPosition), Exprs);
  799.         } else {
  800.           Exprs = Tree_mOneExpr(PatternsPtr->A[i], Exprs);
  801.         }
  802.         if (i <= B_4) break;
  803.       }
  804.   }
  805.   *Last = Exprs;
  806.   DynArray_ReleaseArray((ADDRESS *)&PatternsPtr, &PatternsSize, (LONGINT)sizeof(Tree_tTree));
  807.   return t;
  808. }
  809.  
  810. static void CheckExprList
  811. # ifdef __STDC__
  812. (Tree_tTree t, Tree_tTree Formals)
  813. # else
  814. (t, Formals)
  815. Tree_tTree t, Formals;
  816. # endif
  817. {
  818.   if (t->U_1.V_1.Kind == Tree_NoExpr && Formals->U_1.V_1.Kind != Tree_Formal) {
  819.     return;
  820.   }
  821.   if (t->U_1.V_1.Kind == Tree_NoExpr) {
  822.     Scanner_Error((STRING)"too few expressions or arguments", 32L, t->U_1.V_57.NoExpr.Pos);
  823.     return;
  824.   }
  825.   {
  826.     register Tree_yOneExpr *W_20 = &t->U_1.V_58.OneExpr;
  827.  
  828.     if (W_20->Expr->U_1.V_1.Kind == Tree_DontCare) {
  829.       return;
  830.     }
  831.     if (Formals->U_1.V_1.Kind == Tree_NoFormal) {
  832.       Scanner_Error((STRING)"too many expressions or arguments", 33L, W_20->Expr->U_1.V_60.Expr.Pos);
  833.       return;
  834.     }
  835.     CheckExpr(W_20->Expr, Formals);
  836.     CheckExprList(W_20->Next, Formals->U_1.V_86.Formal.Next);
  837.   }
  838. }
  839.  
  840. static void CheckInParams
  841. # ifdef __STDC__
  842. (Tree_tTree t, Tree_tTree Formals)
  843. # else
  844. (t, Formals)
  845. Tree_tTree t, Formals;
  846. # endif
  847. {
  848.   if (t->U_1.V_1.Kind == Tree_NoExpr || Formals->U_1.V_1.Kind != Tree_Formal) {
  849.     return;
  850.   }
  851.   {
  852.     register Tree_yOneExpr *W_21 = &t->U_1.V_58.OneExpr;
  853.  
  854.     if (W_21->Expr->U_1.V_1.Kind == Tree_DontCare) {
  855.       return;
  856.     }
  857.     if (Formals->U_1.V_86.Formal.Path->U_1.V_92.Var.IsOutput && W_21->Expr->U_1.V_1.Kind == Tree_VarUse && W_21->Expr->U_1.V_62.VarUse.Object != Tree_NoTree && W_21->Expr->U_1.V_62.VarUse.Object->U_1.V_86.Formal.Path->U_1.V_1.Kind == Tree_Var && !W_21->Expr->U_1.V_62.VarUse.Object->U_1.V_86.Formal.Path->U_1.V_92.Var.IsOutput) {
  858.       W_21->Expr->U_1.V_62.VarUse.Object->U_1.V_86.Formal.Path->U_1.V_92.Var.IsRegister = FALSE;
  859.     }
  860.     CheckInParams(W_21->Next, Formals->U_1.V_86.Formal.Next);
  861.   }
  862. }
  863.  
  864. static void CheckCallExprs
  865. # ifdef __STDC__
  866. (Tree_tTree t, Tree_tTree Formals)
  867. # else
  868. (t, Formals)
  869. Tree_tTree t, Formals;
  870. # endif
  871. {
  872.   if (t->U_1.V_1.Kind == Tree_NoExpr && Formals->U_1.V_1.Kind != Tree_Formal) {
  873.     return;
  874.   }
  875.   if (t->U_1.V_1.Kind == Tree_NoExpr) {
  876.     Scanner_Error((STRING)"too few expressions or arguments", 32L, t->U_1.V_57.NoExpr.Pos);
  877.     return;
  878.   }
  879.   {
  880.     register Tree_yOneExpr *W_22 = &t->U_1.V_58.OneExpr;
  881.  
  882.     if (W_22->Expr->U_1.V_1.Kind == Tree_DontCare) {
  883.       W_22->Expr->U_1.V_54.DontCare.Tempos = MakeTempos(Formals);
  884.       return;
  885.     }
  886.     if (Formals->U_1.V_1.Kind == Tree_NoFormal) {
  887.       Scanner_Error((STRING)"too many expressions or arguments", 33L, W_22->Expr->U_1.V_60.Expr.Pos);
  888.       return;
  889.     }
  890.     CheckExprVar(W_22->Expr, Formals);
  891.     CheckCallExprs(W_22->Next, Formals->U_1.V_86.Formal.Next);
  892.   }
  893. }
  894.  
  895. static void CheckExprVar
  896. # ifdef __STDC__
  897. (Tree_tTree t, Tree_tTree Formals)
  898. # else
  899. (t, Formals)
  900. Tree_tTree t, Formals;
  901. # endif
  902. {
  903.   if (t->U_1.V_1.Kind == Tree_Compose) {
  904.     t->U_1.V_61.Compose.Tempo = MakeVar();
  905.     if (Formals->U_1.V_1.Kind == Tree_Formal) {
  906.       t->U_1.V_61.Compose.TypeDesc = Formals->U_1.V_86.Formal.TypeDesc;
  907.     } else {
  908.       t->U_1.V_61.Compose.TypeDesc = t->U_1.V_61.Compose.Object->U_1.V_5.Class.TypeDesc;
  909.     }
  910.   } else if (t->U_1.V_1.Kind == Tree_DontCare1) {
  911.     t->U_1.V_53.DontCare1.Tempo = MakeVar();
  912.     if (Formals->U_1.V_1.Kind == Tree_Formal) {
  913.       t->U_1.V_53.DontCare1.TypeDesc = Formals->U_1.V_86.Formal.TypeDesc;
  914.     }
  915.   }
  916.   CheckExpr(t, Formals);
  917. }
  918.  
  919. static void CheckExpr
  920. # ifdef __STDC__
  921. (Tree_tTree t, Tree_tTree Formals)
  922. # else
  923. (t, Formals)
  924. Tree_tTree t, Formals;
  925. # endif
  926. {
  927.   switch (t->U_1.V_1.Kind) {
  928.   case Tree_Compose:;
  929.     {
  930.       register Tree_yCompose *W_23 = &t->U_1.V_61.Compose;
  931.  
  932.       if (W_23->Selector != Idents_NoIdent) {
  933.         Scanner_Warning((STRING)"label ignored", 13L, W_23->Pos);
  934.       }
  935.       if (Formals->U_1.V_1.Kind == Tree_Formal) {
  936.         CheckSubtype(Formals->U_1.V_86.Formal.TypeDesc, W_23->Object->U_1.V_5.Class.TypeDesc, W_23->Pos);
  937.       }
  938.       if (W_23->Object == Tree_NoTree) {
  939.         CheckExpr(W_23->Expr, dFormals);
  940.       } else {
  941.         CheckExpr2(W_23->Expr);
  942.       }
  943.       CheckExprList(W_23->Exprs, W_23->Object->U_1.V_5.Class.Formals);
  944.     }
  945.     break;
  946.   case Tree_VarUse:;
  947.     {
  948.       register Tree_yVarUse *W_24 = &t->U_1.V_62.VarUse;
  949.  
  950.       if (Sets_IsElement((LONGCARD)W_24->Name, &LabelNames)) {
  951.         W_24->Object = Semantics_IdentifyVar(Decls, W_24->Name);
  952.         if (W_24->Object != Tree_NoTree && Formals->U_1.V_1.Kind == Tree_Formal) {
  953.           CheckSubtype(Formals->U_1.V_86.Formal.TypeDesc, W_24->Object->U_1.V_86.Formal.TypeDesc, W_24->Pos);
  954.         }
  955.       } else if (!Sets_IsElement((LONGCARD)W_24->Name, &ExternNames) && !Sets_IsElement((LONGCARD)W_24->Name, &LocExternNames) && !Sets_IsElement((LONGCARD)W_24->Name, &UserNames)) {
  956.         if (Sets_IsElement(ORD('e'), &Tree_Options)) {
  957.           Scanner_ErrorI((STRING)"label not declared or computed", 30L, W_24->Pos, W_24->Name);
  958.         } else if (Sets_IsElement(ORD('v'), &Tree_Options) && !Sets_IsElement(ORD('s'), &Tree_Options)) {
  959.           Scanner_WarningI((STRING)"label not declared or computed", 30L, W_24->Pos, W_24->Name);
  960.         }
  961.         Sets_Include(&UserNames, (LONGCARD)W_24->Name);
  962.       }
  963.     }
  964.     break;
  965.   case Tree_Nil:;
  966.     {
  967.       register Tree_yNil *W_25 = &t->U_1.V_64.Nil;
  968.  
  969.       if (W_25->Selector != Idents_NoIdent) {
  970.         Scanner_Warning((STRING)"label ignored", 13L, W_25->Pos);
  971.       }
  972.     }
  973.     break;
  974.   case Tree_Call:;
  975.     {
  976.       register Tree_yCall *W_26 = &t->U_1.V_65.Call;
  977.  
  978.       if (W_26->Object == Tree_NoTree) {
  979.         CheckExpr(W_26->Expr, dFormals);
  980.         if (W_26->Expr->U_1.V_1.Kind == Tree_VarUse) {
  981.           ProcName = W_26->Expr->U_1.V_62.VarUse.Name;
  982.         } else if (W_26->Expr->U_1.V_1.Kind == Tree_Binary && W_26->Expr->U_1.V_66.Binary.Lop->U_1.V_1.Kind == Tree_VarUse) {
  983.           ProcName = W_26->Expr->U_1.V_66.Binary.Lop->U_1.V_62.VarUse.Name;
  984.         } else {
  985.           ProcName = Idents_NoIdent;
  986.         }
  987.         if (!Sets_IsElement((LONGCARD)ProcName, &ExternNames) && !Sets_IsElement((LONGCARD)ProcName, &LocExternNames) && !Sets_IsElement((LONGCARD)ProcName, &UserNames)) {
  988.           if (Sets_IsElement(ORD('e'), &Tree_Options)) {
  989.             Scanner_ErrorI((STRING)"subroutine identifier not declared", 34L, W_26->Pos, ProcName);
  990.           } else if (Sets_IsElement(ORD('v'), &Tree_Options) && !Sets_IsElement(ORD('s'), &Tree_Options)) {
  991.             Scanner_WarningI((STRING)"subroutine identifier not declared", 34L, W_26->Pos, ProcName);
  992.           }
  993.           Sets_Include(&UserNames, (LONGCARD)ProcName);
  994.         }
  995.         CheckCallExprs(W_26->Exprs, dFormals);
  996.         CheckCallExprs(W_26->Patterns, dFormals);
  997.       } else if (Tree_IsType(W_26->Object, Tree_Routine)) {
  998.         CheckExpr2(W_26->Expr);
  999.         if (W_26->Object->U_1.V_1.Kind == Tree_Function && Formals->U_1.V_1.Kind == Tree_Formal) {
  1000.           CheckSubtype(Formals->U_1.V_86.Formal.TypeDesc, W_26->Object->U_1.V_34.Function.ReturnForm->U_1.V_86.Formal.TypeDesc, W_26->Pos);
  1001.         }
  1002.         CheckCallExprs(W_26->Exprs, W_26->Object->U_1.V_32.Routine.InForm);
  1003.         CheckCallPatterns(W_26->Patterns, W_26->Object->U_1.V_32.Routine.OutForm);
  1004.         CheckInParams(W_26->Exprs, W_26->Object->U_1.V_32.Routine.InForm);
  1005.       } else {
  1006.         Scanner_Error((STRING)"subroutine identifier required", 30L, W_26->Pos);
  1007.       }
  1008.     }
  1009.     break;
  1010.   case Tree_Binary:;
  1011.     {
  1012.       register Tree_yBinary *W_27 = &t->U_1.V_66.Binary;
  1013.  
  1014.       CheckExprVar(W_27->Lop, dFormals);
  1015.       CheckExprVar(W_27->Rop, dFormals);
  1016.     }
  1017.     break;
  1018.   case Tree_PreOperator:;
  1019.   case Tree_PostOperator:;
  1020.     {
  1021.       register Tree_yPreOperator *W_28 = &t->U_1.V_67.PreOperator;
  1022.  
  1023.       CheckExprVar(W_28->Expr, Formals);
  1024.     }
  1025.     break;
  1026.   case Tree_Index:;
  1027.     {
  1028.       register Tree_yIndex *W_29 = &t->U_1.V_69.Index;
  1029.  
  1030.       CheckExprVar(W_29->Expr, dFormals);
  1031.       CheckExprList(W_29->Exprs, dFormals);
  1032.     }
  1033.     break;
  1034.   case Tree_Parents:;
  1035.     {
  1036.       register Tree_yParents *W_30 = &t->U_1.V_70.Parents;
  1037.  
  1038.       CheckExprVar(W_30->Expr, Formals);
  1039.     }
  1040.     break;
  1041.   case Tree_AttrDesc:;
  1042.     {
  1043.       register Tree_yAttrDesc *W_31 = &t->U_1.V_63.AttrDesc;
  1044.  
  1045.       if (Sets_IsElement((LONGCARD)W_31->Name, &LabelNames)) {
  1046.         W_31->Object = Semantics_IdentifyVar(Decls, W_31->Name);
  1047.         if (W_31->Object->U_1.V_86.Formal.TypeDesc->U_1.V_1.Kind == Tree_NodeTypes) {
  1048.           ActClass = Semantics_LookupClass(W_31->Object->U_1.V_86.Formal.TypeDesc->U_1.V_89.NodeTypes.TreeName->U_1.V_29.TreeName.Classes, Sets_Minimum(&W_31->Object->U_1.V_86.Formal.TypeDesc->U_1.V_89.NodeTypes.Types));
  1049.           W_31->Type = ActClass->U_1.V_5.Class.Name;
  1050.         } else {
  1051.           Scanner_Error((STRING)"tree-type required", 18L, W_31->Pos);
  1052.         }
  1053.       } else {
  1054.         Scanner_Error((STRING)"label not declared or computed", 30L, W_31->Pos);
  1055.       }
  1056.     }
  1057.     break;
  1058.   default :
  1059.     break;
  1060.   }
  1061. }
  1062.  
  1063. static void CheckExpr2
  1064. # ifdef __STDC__
  1065. (Tree_tTree t)
  1066. # else
  1067. (t)
  1068. Tree_tTree t;
  1069. # endif
  1070. {
  1071.   switch (t->U_1.V_1.Kind) {
  1072.   case Tree_VarUse:;
  1073.     {
  1074.       register Tree_yVarUse *W_32 = &t->U_1.V_62.VarUse;
  1075.  
  1076.       W_32->Object = Semantics_IdentifyVar(Decls, W_32->Name);
  1077.     }
  1078.     break;
  1079.   case Tree_Binary:;
  1080.     {
  1081.       register Tree_yBinary *W_33 = &t->U_1.V_66.Binary;
  1082.  
  1083.       CheckExpr2(W_33->Lop);
  1084.       CheckExpr2(W_33->Rop);
  1085.     }
  1086.     break;
  1087.   case Tree_Compose:;
  1088.     CheckExpr(t, dFormals);
  1089.     break;
  1090.   }
  1091. }
  1092.  
  1093. static void CheckPatternList
  1094. # ifdef __STDC__
  1095. (Tree_tTree t, Tree_tTree Formals)
  1096. # else
  1097. (t, Formals)
  1098. Tree_tTree t, Formals;
  1099. # endif
  1100. {
  1101.   Tree_tTree Pattern;
  1102.  
  1103.   if (t->U_1.V_1.Kind == Tree_NoPattern && Formals->U_1.V_1.Kind != Tree_Formal) {
  1104.     return;
  1105.   }
  1106.   if (t->U_1.V_1.Kind == Tree_NoPattern) {
  1107.     Scanner_Error((STRING)"too few patterns", 16L, t->U_1.V_44.NoPattern.Pos);
  1108.     return;
  1109.   }
  1110.   Pattern = t->U_1.V_45.OnePattern.Pattern;
  1111.   if (Pattern->U_1.V_1.Kind == Tree_DontCare) {
  1112.     return;
  1113.   }
  1114.   if (Formals->U_1.V_1.Kind == Tree_NoFormal) {
  1115.     Scanner_Error((STRING)"too many patterns", 17L, t->U_1.V_45.OnePattern.Pattern->U_1.V_49.Pattern.Pos);
  1116.     return;
  1117.   }
  1118.   CheckPattern(Pattern, Formals, Formals->U_1.V_86.Formal.Path);
  1119.   CheckPatternList(t->U_1.V_45.OnePattern.Next, Formals->U_1.V_86.Formal.Next);
  1120. }
  1121.  
  1122. static void CheckSubPatterns
  1123. # ifdef __STDC__
  1124. (Tree_tTree t, Tree_tTree Formals, Tree_tTree Path)
  1125. # else
  1126. (t, Formals, Path)
  1127. Tree_tTree t, Formals, Path;
  1128. # endif
  1129. {
  1130.   Tree_tTree Pattern;
  1131.  
  1132.   if (t->U_1.V_1.Kind == Tree_NoPattern && Formals->U_1.V_1.Kind != Tree_Formal) {
  1133.     return;
  1134.   }
  1135.   if (t->U_1.V_1.Kind == Tree_NoPattern) {
  1136.     Scanner_Error((STRING)"too few patterns", 16L, t->U_1.V_44.NoPattern.Pos);
  1137.     return;
  1138.   }
  1139.   Pattern = t->U_1.V_45.OnePattern.Pattern;
  1140.   if (Pattern->U_1.V_1.Kind == Tree_DontCare) {
  1141.     return;
  1142.   }
  1143.   if (Formals->U_1.V_1.Kind == Tree_NoFormal) {
  1144.     Scanner_Error((STRING)"too many patterns", 17L, Pattern->U_1.V_49.Pattern.Pos);
  1145.     return;
  1146.   }
  1147.   CheckPattern(Pattern, Formals, Tree_mField(Path, Formals->U_1.V_86.Formal.Name));
  1148.   CheckSubPatterns(t->U_1.V_45.OnePattern.Next, Formals->U_1.V_86.Formal.Next, Path);
  1149. }
  1150.  
  1151. static void CheckCallPatterns
  1152. # ifdef __STDC__
  1153. (Tree_tTree t, Tree_tTree Formals)
  1154. # else
  1155. (t, Formals)
  1156. Tree_tTree t, Formals;
  1157. # endif
  1158. {
  1159.   if (t->U_1.V_1.Kind == Tree_NoPattern && Formals->U_1.V_1.Kind != Tree_Formal) {
  1160.     return;
  1161.   }
  1162.   if (t->U_1.V_1.Kind == Tree_NoPattern) {
  1163.     Scanner_Error((STRING)"too few patterns or arguments", 29L, t->U_1.V_44.NoPattern.Pos);
  1164.     return;
  1165.   }
  1166.   {
  1167.     register Tree_yOnePattern *W_34 = &t->U_1.V_45.OnePattern;
  1168.  
  1169.     if (W_34->Pattern->U_1.V_1.Kind == Tree_DontCare) {
  1170.       W_34->Pattern->U_1.V_54.DontCare.Tempos = MakeTempos(Formals);
  1171.       return;
  1172.     }
  1173.     if (Formals->U_1.V_1.Kind == Tree_NoFormal) {
  1174.       Scanner_Error((STRING)"too many patterns or arguments", 30L, W_34->Pattern->U_1.V_49.Pattern.Pos);
  1175.       return;
  1176.     }
  1177.     W_34->Pattern->U_1.V_49.Pattern.Tempo = MakeVar();
  1178.     W_34->Pattern->U_1.V_49.Pattern.TypeDesc = Formals->U_1.V_86.Formal.TypeDesc;
  1179.     CheckPattern(W_34->Pattern, Formals, Tree_mVar(W_34->Pattern->U_1.V_49.Pattern.Tempo, FALSE, TRUE));
  1180.     CheckCallPatterns(W_34->Next, Formals->U_1.V_86.Formal.Next);
  1181.   }
  1182. }
  1183.  
  1184. static void CheckPattern
  1185. # ifdef __STDC__
  1186. (Tree_tTree t, Tree_tTree Formals, Tree_tTree Path)
  1187. # else
  1188. (t, Formals, Path)
  1189. Tree_tTree t, Formals, Path;
  1190. # endif
  1191. {
  1192.   t->U_1.V_49.Pattern.Path = Path;
  1193.   switch (t->U_1.V_1.Kind) {
  1194.   case Tree_Decompose:;
  1195.     {
  1196.       register Tree_yDecompose *W_35 = &t->U_1.V_50.Decompose;
  1197.  
  1198.       if (W_35->Selector != Idents_NoIdent) {
  1199.         if (Sets_IsElement((LONGCARD)W_35->Selector, &LabelNames)) {
  1200.           Scanner_Error((STRING)"label multiply declared", 23L, W_35->Pos);
  1201.         } else {
  1202.           Sets_Include(&LabelNames, (LONGCARD)W_35->Selector);
  1203.         }
  1204.         if (W_35->Widen && Formals->U_1.V_1.Kind == Tree_Formal) {
  1205.           Decls = Tree_mFormal(Decls, W_35->Selector, Formals->U_1.V_86.Formal.TypeDesc, W_35->Path);
  1206.         } else {
  1207.           Decls = Tree_mFormal(Decls, W_35->Selector, W_35->Object->U_1.V_5.Class.TypeDesc, W_35->Path);
  1208.         }
  1209.       }
  1210.       if (Formals->U_1.V_1.Kind == Tree_Formal) {
  1211.         CheckSubtype(Formals->U_1.V_86.Formal.TypeDesc, W_35->Object->U_1.V_5.Class.TypeDesc, W_35->Pos);
  1212.       }
  1213.       if (W_35->Object == Tree_NoTree) {
  1214.         CheckExpr(W_35->Expr, dFormals);
  1215.       } else {
  1216.         CheckExpr2(W_35->Expr);
  1217.       }
  1218.       CheckSubPatterns(W_35->Patterns, W_35->Object->U_1.V_5.Class.Formals, Tree_mConsType(W_35->Path, W_35->Object->U_1.V_5.Class.Name));
  1219.     }
  1220.     break;
  1221.   case Tree_VarDef:;
  1222.     {
  1223.       register Tree_yVarDef *W_36 = &t->U_1.V_51.VarDef;
  1224.  
  1225.       if (Sets_IsElement((LONGCARD)W_36->Name, &LabelNames)) {
  1226.         if (!Sets_IsElement(ORD('k'), &Tree_Options)) {
  1227.           Scanner_Error((STRING)"label multiply declared", 23L, W_36->Pos);
  1228.         }
  1229.         W_36->Object = Semantics_IdentifyVar(Decls, W_36->Name);
  1230.         if (Formals->U_1.V_1.Kind == Tree_Formal) {
  1231.           CheckType(Formals->U_1.V_86.Formal.TypeDesc, W_36->Object->U_1.V_86.Formal.TypeDesc, W_36->Pos);
  1232.         }
  1233.       } else {
  1234.         Sets_Include(&LabelNames, (LONGCARD)W_36->Name);
  1235.         if (Formals->U_1.V_1.Kind == Tree_Formal) {
  1236.           Decls = Tree_mFormal(Decls, W_36->Name, Formals->U_1.V_86.Formal.TypeDesc, W_36->Path);
  1237.         }
  1238.         W_36->Object = Tree_NoTree;
  1239.       }
  1240.     }
  1241.     break;
  1242.   case Tree_NilTest:;
  1243.     {
  1244.       register Tree_yNilTest *W_37 = &t->U_1.V_52.NilTest;
  1245.  
  1246.       if (W_37->Selector != Idents_NoIdent) {
  1247.         if (Sets_IsElement((LONGCARD)W_37->Selector, &LabelNames)) {
  1248.           Scanner_Error((STRING)"label multiply declared", 23L, W_37->Pos);
  1249.         } else {
  1250.           Sets_Include(&LabelNames, (LONGCARD)W_37->Selector);
  1251.         }
  1252.         if (Formals->U_1.V_1.Kind == Tree_Formal) {
  1253.           Decls = Tree_mFormal(Decls, W_37->Selector, Formals->U_1.V_86.Formal.TypeDesc, W_37->Path);
  1254.         }
  1255.       }
  1256.     }
  1257.     break;
  1258.   case Tree_Value:;
  1259.     CheckExprVar(t->U_1.V_55.Value.Expr, dFormals);
  1260.     break;
  1261.   default :
  1262.     break;
  1263.   }
  1264. }
  1265.  
  1266. static Idents_tIdent MakeVar
  1267. # ifdef __STDC__
  1268. ()
  1269. # else
  1270. ()
  1271. # endif
  1272. {
  1273.   Strings_tString String1, String2;
  1274.  
  1275.   INC(VarCount);
  1276.   Strings_ArrayToString((STRING)"yyV", 3L, &String1);
  1277.   Strings_IntToString(VarCount, &String2);
  1278.   Strings_Concatenate(&String1, &String2);
  1279.   return Idents_MakeIdent(&String1);
  1280. }
  1281.  
  1282. static Tree_tTree MakeTempos
  1283. # ifdef __STDC__
  1284. (Tree_tTree Formals)
  1285. # else
  1286. (Formals)
  1287. Tree_tTree Formals;
  1288. # endif
  1289. {
  1290.   if (Formals->U_1.V_1.Kind == Tree_Formal) {
  1291.     {
  1292.       register Tree_yFormal *W_38 = &Formals->U_1.V_86.Formal;
  1293.  
  1294.       return Tree_mFormal(MakeTempos(W_38->Next), MakeVar(), W_38->TypeDesc, W_38->Path);
  1295.     }
  1296.   } else {
  1297.     return nNoFormal;
  1298.   }
  1299. }
  1300.  
  1301. static void yyAbort
  1302. # ifdef __STDC__
  1303. (CHAR yyFunction[], LONGCARD O_1)
  1304. # else
  1305. (yyFunction, O_1)
  1306. CHAR yyFunction[];
  1307. LONGCARD O_1;
  1308. # endif
  1309. {
  1310.   OPEN_ARRAY_LOCALS
  1311.  
  1312.   ALLOC_OPEN_ARRAYS(O_1 * sizeof(CHAR), 1)
  1313.   COPY_OPEN_ARRAY(yyFunction, O_1, CHAR)
  1314.   IO_WriteS((System_tFile)IO_StdError, (STRING)"Error: module Semantics, routine ", 33L);
  1315.   IO_WriteS((System_tFile)IO_StdError, yyFunction, O_1);
  1316.   IO_WriteS((System_tFile)IO_StdError, (STRING)" failed", 7L);
  1317.   IO_WriteNl((System_tFile)IO_StdError);
  1318.   (*Semantics_Exit)();
  1319.   FREE_OPEN_ARRAYS
  1320. }
  1321.  
  1322. static BOOLEAN yyIsEqual
  1323. # ifdef __STDC__
  1324. (BYTE yya[], LONGCARD O_3, BYTE yyb[], LONGCARD O_2)
  1325. # else
  1326. (yya, O_3, yyb, O_2)
  1327. BYTE yya[];
  1328. LONGCARD O_3;
  1329. BYTE yyb[];
  1330. LONGCARD O_2;
  1331. # endif
  1332. {
  1333.   INTEGER yyi;
  1334.   OPEN_ARRAY_LOCALS
  1335.  
  1336.   ALLOC_OPEN_ARRAYS(O_2 * sizeof(WORD) + O_3 * sizeof(WORD), 2)
  1337.   COPY_OPEN_ARRAY(yyb, O_2, WORD)
  1338.   COPY_OPEN_ARRAY(yya, O_3, WORD)
  1339.   {
  1340.     LONGINT B_5 = 0, B_6 = (INTEGER)(O_3 - 1);
  1341.  
  1342.     if (B_5 <= B_6)
  1343.       for (yyi = B_5;; yyi += 1) {
  1344.         if (yya[yyi] != yyb[yyi]) {
  1345.           FREE_OPEN_ARRAYS
  1346.           return FALSE;
  1347.         }
  1348.         if (yyi >= B_6) break;
  1349.       }
  1350.   }
  1351.   FREE_OPEN_ARRAYS
  1352.   return TRUE;
  1353. }
  1354.  
  1355. void Semantics_Semantics
  1356. # ifdef __STDC__
  1357. (Tree_tTree t)
  1358. # else
  1359. (t)
  1360. Tree_tTree t;
  1361. # endif
  1362. {
  1363.   struct S_4 yyTempo;
  1364.  
  1365.   if (t == Tree_NoTree) {
  1366.     return;
  1367.   }
  1368.   if (t->U_1.V_1.Kind == Tree_Spec) {
  1369.     {
  1370.       register Tree_ySpec *W_39 = &t->U_1.V_26.Spec;
  1371.  
  1372.       Semantics_TypeCount = Idents_MaxIdent();
  1373.       Sets_MakeSet(&RoutineNames, (LONGCARD)Semantics_TypeCount);
  1374.       Sets_MakeSet(&LabelNames, (LONGCARD)Semantics_TypeCount);
  1375.       Sets_MakeSet(&ParamNames, (LONGCARD)Semantics_TypeCount);
  1376.       Sets_MakeSet(&Semantics_TypeNames, (LONGCARD)Semantics_TypeCount);
  1377.       Sets_MakeSet(&ExternNames, (LONGCARD)Semantics_TypeCount);
  1378.       Sets_MakeSet(&LocExternNames, (LONGCARD)Semantics_TypeCount);
  1379.       Sets_MakeSet(&Semantics_UserTypes, (LONGCARD)Semantics_TypeCount);
  1380.       Sets_MakeSet(&UserNames, (LONGCARD)Semantics_TypeCount);
  1381.       ClassFormals(W_39->TreeNames);
  1382.       Semantics_Semantics(W_39->Public);
  1383.       CollectExtern(W_39->Extern, &ExternNames);
  1384.       ProcFormals(W_39->Routines);
  1385.       Semantics_Semantics(W_39->Routines);
  1386.       if (Sets_IsElement(ORD('o'), &Tree_Options) && !Sets_IsEmpty(UserNames)) {
  1387.         IO_WriteNl((System_tFile)IO_StdOutput);
  1388.         IO_WriteS((System_tFile)IO_StdOutput, (STRING)"Undefined External Names", 24L);
  1389.         IO_WriteNl((System_tFile)IO_StdOutput);
  1390.         IO_WriteS((System_tFile)IO_StdOutput, (STRING)"------------------------", 24L);
  1391.         IO_WriteNl((System_tFile)IO_StdOutput);
  1392.         IO_WriteNl((System_tFile)IO_StdOutput);
  1393.         {
  1394.           LONGCARD B_7 = 1, B_8 = Semantics_TypeCount;
  1395.  
  1396.           if (B_7 <= B_8)
  1397.             for (i = B_7;; i += 1) {
  1398.               if (Sets_IsElement(i, &UserNames)) {
  1399.                 Idents_WriteIdent((System_tFile)IO_StdOutput, (SHORTCARD)i);
  1400.                 IO_WriteNl((System_tFile)IO_StdOutput);
  1401.               }
  1402.               if (i >= B_8) break;
  1403.             }
  1404.         }
  1405.       }
  1406.       return;
  1407.     }
  1408.   }
  1409.   if (t->U_1.V_1.Kind == Tree_Name) {
  1410.     {
  1411.       register Tree_yName *W_40 = &t->U_1.V_25.Name;
  1412.  
  1413.       W_40->Object = IdentifyProc(W_40->Name);
  1414.       if (W_40->Object == Tree_NoTree) {
  1415.         Scanner_ErrorI((STRING)"subroutine identifier not declared", 34L, W_40->Pos, W_40->Name);
  1416.       } else {
  1417.         W_40->Object->U_1.V_32.Routine.IsExtern = TRUE;
  1418.       }
  1419.       Semantics_Semantics(W_40->Next);
  1420.       return;
  1421.     }
  1422.   }
  1423.   if (t->U_1.V_1.Kind == Tree_Procedure) {
  1424.     {
  1425.       register Tree_yProcedure *W_41 = &t->U_1.V_33.Procedure;
  1426.  
  1427.       Sets_AssignEmpty(&LocExternNames);
  1428.       CollectExtern(W_41->Extern, &LocExternNames);
  1429.       if (Sets_IsElement((LONGCARD)W_41->Name, &RoutineNames)) {
  1430.         Scanner_Error((STRING)"routine identifier multiply declared", 36L, W_41->Pos);
  1431.       } else {
  1432.         Sets_Include(&RoutineNames, (LONGCARD)W_41->Name);
  1433.       }
  1434.       Sets_AssignEmpty(&ParamNames);
  1435.       Check(W_41->InParams);
  1436.       Check(W_41->OutParams);
  1437.       InFormals = W_41->InForm;
  1438.       OutFormals = W_41->OutForm;
  1439.       Parameters = W_41->ParamDecls;
  1440.       IsFunction = FALSE;
  1441.       RuleCount = 0;
  1442.       Check(W_41->Rules);
  1443.       Semantics_Semantics(W_41->Next);
  1444.       return;
  1445.     }
  1446.   }
  1447.   if (t->U_1.V_1.Kind == Tree_Predicate) {
  1448.     {
  1449.       register Tree_yPredicate *W_42 = &t->U_1.V_35.Predicate;
  1450.  
  1451.       Sets_AssignEmpty(&LocExternNames);
  1452.       CollectExtern(W_42->Extern, &LocExternNames);
  1453.       if (Sets_IsElement((LONGCARD)W_42->Name, &RoutineNames)) {
  1454.         Scanner_Error((STRING)"routine identifier multiply declared", 36L, W_42->Pos);
  1455.       } else {
  1456.         Sets_Include(&RoutineNames, (LONGCARD)W_42->Name);
  1457.       }
  1458.       Sets_AssignEmpty(&ParamNames);
  1459.       Check(W_42->InParams);
  1460.       Check(W_42->OutParams);
  1461.       InFormals = W_42->InForm;
  1462.       OutFormals = W_42->OutForm;
  1463.       Parameters = W_42->ParamDecls;
  1464.       IsFunction = FALSE;
  1465.       RuleCount = 0;
  1466.       Check(W_42->Rules);
  1467.       Semantics_Semantics(W_42->Next);
  1468.       return;
  1469.     }
  1470.   }
  1471.   if (t->U_1.V_1.Kind == Tree_Function) {
  1472.     {
  1473.       register Tree_yFunction *W_43 = &t->U_1.V_34.Function;
  1474.  
  1475.       Sets_AssignEmpty(&LocExternNames);
  1476.       CollectExtern(W_43->Extern, &LocExternNames);
  1477.       if (Sets_IsElement((LONGCARD)W_43->Name, &RoutineNames)) {
  1478.         Scanner_Error((STRING)"routine identifier multiply declared", 36L, W_43->Pos);
  1479.       } else {
  1480.         Sets_Include(&RoutineNames, (LONGCARD)W_43->Name);
  1481.       }
  1482.       Sets_AssignEmpty(&ParamNames);
  1483.       Check(W_43->InParams);
  1484.       Check(W_43->OutParams);
  1485.       Check(W_43->ReturnParams);
  1486.       InFormals = W_43->InForm;
  1487.       OutFormals = W_43->OutForm;
  1488.       ReturnFormal = W_43->ReturnForm;
  1489.       Parameters = W_43->ParamDecls;
  1490.       IsFunction = TRUE;
  1491.       RuleCount = 0;
  1492.       Check(W_43->Rules);
  1493.       Semantics_Semantics(W_43->Next);
  1494.       return;
  1495.     }
  1496.   }
  1497. }
  1498.  
  1499. static void CollectExtern
  1500. # ifdef __STDC__
  1501. (Tree_tTree t, Sets_tSet *Names)
  1502. # else
  1503. (t, Names)
  1504. Tree_tTree t;
  1505. Sets_tSet *Names;
  1506. # endif
  1507. {
  1508.   struct S_5 yyTempo;
  1509.  
  1510.   if (t == Tree_NoTree) {
  1511.     return;
  1512.   }
  1513.   if (t->U_1.V_1.Kind == Tree_Name) {
  1514.     {
  1515.       register Tree_yName *W_44 = &t->U_1.V_25.Name;
  1516.  
  1517.       Sets_Include(Names, (LONGCARD)W_44->Name);
  1518.       CollectExtern(W_44->Next, Names);
  1519.       return;
  1520.     }
  1521.   }
  1522. }
  1523.  
  1524. static void ProcFormals
  1525. # ifdef __STDC__
  1526. (Tree_tTree t)
  1527. # else
  1528. (t)
  1529. Tree_tTree t;
  1530. # endif
  1531. {
  1532.   struct S_6 yyTempo;
  1533.  
  1534.   if (t == Tree_NoTree) {
  1535.     return;
  1536.   }
  1537.   switch (t->U_1.V_1.Kind) {
  1538.   case Tree_Procedure:;
  1539.     {
  1540.       register Tree_yProcedure *W_45 = &t->U_1.V_33.Procedure;
  1541.  
  1542.       Args = nNoFormal;
  1543.       Decls = nNoFormal;
  1544.       Sets_AssignEmpty(&ParamNames);
  1545.       IsOutput = FALSE;
  1546.       ProcFormals(W_45->InParams);
  1547.       W_45->InForm = Tree_ReverseTree(Args);
  1548.       Args = nNoFormal;
  1549.       IsOutput = TRUE;
  1550.       ProcFormals(W_45->OutParams);
  1551.       W_45->OutForm = Tree_ReverseTree(Args);
  1552.       W_45->ParamDecls = Decls;
  1553.       ProcFormals(W_45->Next);
  1554.       return;
  1555.     }
  1556.     break;
  1557.   case Tree_Predicate:;
  1558.     {
  1559.       register Tree_yPredicate *W_46 = &t->U_1.V_35.Predicate;
  1560.  
  1561.       Args = nNoFormal;
  1562.       Decls = nNoFormal;
  1563.       Sets_AssignEmpty(&ParamNames);
  1564.       IsOutput = FALSE;
  1565.       ProcFormals(W_46->InParams);
  1566.       W_46->InForm = Tree_ReverseTree(Args);
  1567.       Args = nNoFormal;
  1568.       IsOutput = TRUE;
  1569.       ProcFormals(W_46->OutParams);
  1570.       W_46->OutForm = Tree_ReverseTree(Args);
  1571.       W_46->ParamDecls = Decls;
  1572.       ProcFormals(W_46->Next);
  1573.       return;
  1574.     }
  1575.     break;
  1576.   case Tree_Function:;
  1577.     {
  1578.       register Tree_yFunction *W_47 = &t->U_1.V_34.Function;
  1579.  
  1580.       Args = nNoFormal;
  1581.       Decls = nNoFormal;
  1582.       Sets_AssignEmpty(&ParamNames);
  1583.       IsOutput = FALSE;
  1584.       ProcFormals(W_47->InParams);
  1585.       W_47->InForm = Tree_ReverseTree(Args);
  1586.       Args = nNoFormal;
  1587.       IsOutput = TRUE;
  1588.       ProcFormals(W_47->OutParams);
  1589.       W_47->OutForm = Tree_ReverseTree(Args);
  1590.       Args = nNoFormal;
  1591.       IsOutput = TRUE;
  1592.       ProcFormals(W_47->ReturnParams);
  1593.       W_47->ReturnForm = Tree_ReverseTree(Args);
  1594.       W_47->ParamDecls = Decls;
  1595.       ProcFormals(W_47->Next);
  1596.       return;
  1597.     }
  1598.     break;
  1599.   case Tree_Param:;
  1600.     {
  1601.       register Tree_yParam *W_48 = &t->U_1.V_38.Param;
  1602.  
  1603.       if (Sets_IsElement((LONGCARD)W_48->Name, &ParamNames)) {
  1604.         Scanner_Error((STRING)"parameter identifier multiply declared", 38L, W_48->Pos);
  1605.       } else {
  1606.         Sets_Include(&ParamNames, (LONGCARD)W_48->Name);
  1607.       }
  1608.       ParamName = W_48->Name;
  1609.       Mode = W_48->IsRef;
  1610.       ProcFormals(W_48->Type);
  1611.       ProcFormals(W_48->Next);
  1612.       return;
  1613.     }
  1614.     break;
  1615.   case Tree_Type:;
  1616.     {
  1617.       register Tree_yType *W_49 = &t->U_1.V_39.Type;
  1618.  
  1619.       if (W_49->Name != Idents_NoIdent && W_49->Names->U_1.V_1.Kind != Tree_NoName) {
  1620.         TreeName = IdentifyTree(W_49->Name);
  1621.         if (TreeName != Tree_NoTree) {
  1622.           Sets_MakeSet(&ActTypes, (LONGCARD)TreeName->U_1.V_29.TreeName.ClassCount);
  1623.         } else {
  1624.           Scanner_Error((STRING)"tree type not declared", 22L, W_49->Pos);
  1625.         }
  1626.       } else if (W_49->Name != Idents_NoIdent && W_49->Names->U_1.V_1.Kind == Tree_NoName) {
  1627.         TreeName = IdentifyTree(W_49->Name);
  1628.         if (TreeName != Tree_NoTree) {
  1629.           Sets_MakeSet(&ActTypes, (LONGCARD)TreeName->U_1.V_29.TreeName.ClassCount);
  1630.           MakeTypes((LONGINT)TreeName->U_1.V_29.TreeName.Classes->U_1.V_5.Class.Index, TreeName->U_1.V_29.TreeName.Classes, &ActTypes);
  1631.         } else {
  1632.           ActClass = IdentifyClass2(W_49->Name, &TreeName);
  1633.           if (ActClass != Tree_NoTree) {
  1634.             Sets_MakeSet(&ActTypes, (LONGCARD)TreeName->U_1.V_29.TreeName.ClassCount);
  1635.             MakeTypes((LONGINT)ActClass->U_1.V_5.Class.Index, ActClass->U_1.V_5.Class.Extensions, &ActTypes);
  1636.           }
  1637.         }
  1638.       } else if (W_49->Name == Idents_NoIdent && W_49->Names->U_1.V_1.Kind != Tree_NoName) {
  1639.         ActClass = IdentifyClass2(W_49->Names->U_1.V_25.Name.Name, &TreeName);
  1640.         if (ActClass != Tree_NoTree) {
  1641.           Sets_MakeSet(&ActTypes, (LONGCARD)TreeName->U_1.V_29.TreeName.ClassCount);
  1642.         } else {
  1643.           Scanner_Error((STRING)"node type not declared", 22L, W_49->Names->U_1.V_25.Name.Pos);
  1644.         }
  1645.       } else {
  1646.         TreeName = Tree_NoTree;
  1647.       }
  1648.       if (TreeName != Tree_NoTree) {
  1649.         ActTree = TreeName->U_1.V_29.TreeName.Classes;
  1650.         ProcFormals(W_49->Names);
  1651.         Node = Tree_mNodeTypes(TreeName, ActTypes);
  1652.       } else {
  1653.         if (W_49->Name == Idents_NoIdent) {
  1654.           Scanner_Error((STRING)"incorrect type", 14L, W_49->Pos);
  1655.         } else {
  1656.           Sets_Include(&Semantics_TypeNames, (LONGCARD)W_49->Name);
  1657.         }
  1658.         Node = Tree_mUserType(W_49->Name);
  1659.       }
  1660.       Var = Tree_mVar(ParamName, (BOOLEAN)(IsOutput || Mode), TRUE);
  1661.       Args = Tree_mFormal(Args, ParamName, Node, Var);
  1662.       Decls = Tree_mFormal(Decls, ParamName, Node, Var);
  1663.       return;
  1664.     }
  1665.     break;
  1666.   case Tree_Name:;
  1667.     {
  1668.       register Tree_yName *W_50 = &t->U_1.V_25.Name;
  1669.  
  1670.       ActClass = IdentifyClass(ActTree, W_50->Name);
  1671.       if (ActClass != Tree_NoTree) {
  1672.         Sets_Include(&ActTypes, (LONGCARD)ActClass->U_1.V_5.Class.Index);
  1673.         Tree_ForallClasses(ActClass->U_1.V_5.Class.Extensions, (Tree_ProcOfT)ProcFormals);
  1674.       } else {
  1675.         Scanner_Error((STRING)"node type not declared", 22L, W_50->Pos);
  1676.       }
  1677.       ProcFormals(W_50->Next);
  1678.       return;
  1679.     }
  1680.     break;
  1681.   case Tree_Class:;
  1682.     {
  1683.       register Tree_yClass *W_51 = &t->U_1.V_5.Class;
  1684.  
  1685.       Sets_Include(&ActTypes, (LONGCARD)W_51->Index);
  1686.       return;
  1687.     }
  1688.     break;
  1689.   default :
  1690.     break;
  1691.   }
  1692. }
  1693.  
  1694. static void ClassFormals
  1695. # ifdef __STDC__
  1696. (Tree_tTree t)
  1697. # else
  1698. (t)
  1699. Tree_tTree t;
  1700. # endif
  1701. {
  1702.   struct S_7 yyTempo;
  1703.  
  1704.   if (t == Tree_NoTree) {
  1705.     return;
  1706.   }
  1707.   if (t->U_1.V_1.Kind == Tree_TreeName) {
  1708.     {
  1709.       register Tree_yTreeName *W_52 = &t->U_1.V_29.TreeName;
  1710.  
  1711.       ActTree = t;
  1712.       W_52->ClassCount = 0;
  1713.       Tree_ForallClasses(W_52->Classes, (Tree_ProcOfT)CountClasses);
  1714.       Tree_ForallClasses(W_52->Classes, (Tree_ProcOfT)ClassTypes);
  1715.       Tree_ForallClasses(W_52->Classes, (Tree_ProcOfT)ClassFormals);
  1716.       ClassFormals(W_52->Next);
  1717.       return;
  1718.     }
  1719.   }
  1720.   if (t->U_1.V_1.Kind == Tree_Class) {
  1721.     {
  1722.       register Tree_yClass *W_53 = &t->U_1.V_5.Class;
  1723.  
  1724.       Args = nNoFormal;
  1725.       Tree_ForallAttributes(t, (Tree_ProcOfT)ClassFormals);
  1726.       W_53->Formals = Tree_ReverseTree(Args);
  1727.       return;
  1728.     }
  1729.   }
  1730.   if (t->U_1.V_1.Kind == Tree_Child) {
  1731.     {
  1732.       register Tree_yChild *W_54 = &t->U_1.V_9.Child;
  1733.  
  1734.       ActClass = IdentifyClass(ActTree->U_1.V_29.TreeName.Classes, W_54->Type);
  1735.       Args = Tree_mFormal(Args, W_54->Name, ActClass->U_1.V_5.Class.TypeDesc, (Tree_tTree)Tree_NoTree);
  1736.       return;
  1737.     }
  1738.   }
  1739.   if (t->U_1.V_1.Kind == Tree_Attribute) {
  1740.     {
  1741.       register Tree_yAttribute *W_55 = &t->U_1.V_10.Attribute;
  1742.  
  1743.       if (((SET_ELEM(Tree_Test) | SET_ELEM(Tree_Dummy)) & W_55->Properties) == 0X0L) {
  1744.         Args = Tree_mFormal(Args, W_55->Name, Tree_mUserType(W_55->Type), (Tree_tTree)Tree_NoTree);
  1745.         Sets_Include(&Semantics_TypeNames, (LONGCARD)W_55->Type);
  1746.       }
  1747.       return;
  1748.     }
  1749.   }
  1750. }
  1751.  
  1752. static void CountClasses
  1753. # ifdef __STDC__
  1754. (Tree_tTree t)
  1755. # else
  1756. (t)
  1757. Tree_tTree t;
  1758. # endif
  1759. {
  1760.   struct S_8 yyTempo;
  1761.  
  1762.   if (t == Tree_NoTree) {
  1763.     return;
  1764.   }
  1765.   if (t->U_1.V_1.Kind == Tree_Class) {
  1766.     {
  1767.       register Tree_yClass *W_56 = &t->U_1.V_5.Class;
  1768.  
  1769.       INC(ActTree->U_1.V_29.TreeName.ClassCount);
  1770.       W_56->Index = ActTree->U_1.V_29.TreeName.ClassCount;
  1771.       return;
  1772.     }
  1773.   }
  1774. }
  1775.  
  1776. static void ClassTypes
  1777. # ifdef __STDC__
  1778. (Tree_tTree t)
  1779. # else
  1780. (t)
  1781. Tree_tTree t;
  1782. # endif
  1783. {
  1784.   struct S_9 yyTempo;
  1785.  
  1786.   if (t == Tree_NoTree) {
  1787.     return;
  1788.   }
  1789.   if (t->U_1.V_1.Kind == Tree_Class) {
  1790.     {
  1791.       register Tree_yClass *W_57 = &t->U_1.V_5.Class;
  1792.  
  1793.       W_57->TypeDesc = Tree_mNodeTypes(ActTree, ActTypes);
  1794.       Sets_MakeSet(&W_57->TypeDesc->U_1.V_89.NodeTypes.Types, (LONGCARD)ActTree->U_1.V_29.TreeName.ClassCount);
  1795.       MakeTypes((LONGINT)W_57->Index, W_57->Extensions, &W_57->TypeDesc->U_1.V_89.NodeTypes.Types);
  1796.       return;
  1797.     }
  1798.   }
  1799. }
  1800.  
  1801. static void Check
  1802. # ifdef __STDC__
  1803. (Tree_tTree t)
  1804. # else
  1805. (t)
  1806. Tree_tTree t;
  1807. # endif
  1808. {
  1809.   struct S_10 yyTempo;
  1810.  
  1811.   if (t == Tree_NoTree) {
  1812.     return;
  1813.   }
  1814.   if (t->U_1.V_1.Kind == Tree_Reject) {
  1815.     if (Tree_IsType(t->U_1.V_79.Reject.Next, Tree_Statement)) {
  1816.       for (;;) {
  1817.         {
  1818.           register Tree_yReject *W_58 = &t->U_1.V_79.Reject;
  1819.  
  1820.           Scanner_Warning((STRING)"statement not reachable", 23L, t->U_1.V_79.Reject.Next->U_1.V_75.Statement.Pos);
  1821.           goto EXIT_1;
  1822.         }
  1823.       } EXIT_1:;
  1824.     }
  1825.   }
  1826.   if (t->U_1.V_1.Kind == Tree_Fail) {
  1827.     if (Tree_IsType(t->U_1.V_80.Fail.Next, Tree_Statement)) {
  1828.       for (;;) {
  1829.         {
  1830.           register Tree_yFail *W_59 = &t->U_1.V_80.Fail;
  1831.  
  1832.           Scanner_Warning((STRING)"statement not reachable", 23L, t->U_1.V_80.Fail.Next->U_1.V_75.Statement.Pos);
  1833.           goto EXIT_2;
  1834.         }
  1835.       } EXIT_2:;
  1836.     }
  1837.     {
  1838.       register Tree_yFail *W_60 = &t->U_1.V_80.Fail;
  1839.  
  1840.       if (IsFunction) {
  1841.         Scanner_Error((STRING)"FAIL not allowed in function", 28L, W_60->Pos);
  1842.       }
  1843.       Check(W_60->Next);
  1844.       return;
  1845.     }
  1846.   }
  1847.   switch (t->U_1.V_1.Kind) {
  1848.   case Tree_Param:;
  1849.     {
  1850.       register Tree_yParam *W_61 = &t->U_1.V_38.Param;
  1851.  
  1852.       Sets_Include(&ParamNames, (LONGCARD)W_61->Name);
  1853.       Check(W_61->Next);
  1854.       return;
  1855.     }
  1856.     break;
  1857.   case Tree_Rule:;
  1858.     {
  1859.       register Tree_yRule *W_62 = &t->U_1.V_42.Rule;
  1860.  
  1861.       INC(RuleCount);
  1862.       W_62->Index = RuleCount;
  1863.       W_62->Patterns = TransformName(W_62->Patterns, InFormals);
  1864.       W_62->Patterns = TransformPattern(W_62->Patterns);
  1865.       W_62->Exprs = TransformName(W_62->Exprs, OutFormals);
  1866.       W_62->Exprs = TransformExpr(W_62->Exprs);
  1867.       W_62->Expr = TransformExpr(W_62->Expr);
  1868.       W_62->Statements = TransformStmt(W_62->Statements);
  1869.       VarCount = 0;
  1870.       HasLocals = FALSE;
  1871.       Decls = Parameters;
  1872.       Sets_Assign(&LabelNames, ParamNames);
  1873.       CheckPatternList(W_62->Patterns, InFormals);
  1874.       Check(W_62->Patterns);
  1875.       Check(W_62->Statements);
  1876.       CheckExprList(W_62->Exprs, OutFormals);
  1877.       Check(W_62->Exprs);
  1878.       if (IsFunction) {
  1879.         if (W_62->Expr->U_1.V_1.Kind == Tree_NoExpr) {
  1880.           if (!HasReject(W_62->Statements)) {
  1881.             Scanner_Error((STRING)"function requires RETURN expression", 35L, W_62->Expr->U_1.V_60.Expr.Pos);
  1882.           }
  1883.         } else {
  1884.           CheckExprVar(W_62->Expr, ReturnFormal);
  1885.           Success = FALSE;
  1886.           Check(W_62->Expr);
  1887.           W_62->HasPatterns = Success;
  1888.           if (W_62->HasPatterns && W_62->Expr->U_1.V_1.Kind != Tree_Compose && t->U_1.V_1.Kind != Tree_DontCare1) {
  1889.             W_62->Tempo = MakeVar();
  1890.           }
  1891.         }
  1892.       }
  1893.       if (!IsFunction && W_62->Expr->U_1.V_1.Kind != Tree_NoExpr) {
  1894.         Scanner_Error((STRING)"illegal RETURN", 14L, W_62->Expr->U_1.V_60.Expr.Pos);
  1895.       }
  1896.       W_62->VarDecls = Decls;
  1897.       if (Sets_IsElement(ORD('c'), &Tree_Options)) {
  1898.         W_62->HasTempos = VarCount > 0 || HasLocals;
  1899.       } else {
  1900.         W_62->HasTempos = VarCount > 0 || HasLocals || W_62->HasPatterns;
  1901.       }
  1902.       CheckTargetCode(W_62->Patterns);
  1903.       CheckTargetCode(W_62->Exprs);
  1904.       if (IsFunction) {
  1905.         CheckTargetCode(W_62->Expr);
  1906.       }
  1907.       CheckTargetCode(W_62->Statements);
  1908.       Check(W_62->Next);
  1909.       return;
  1910.     }
  1911.     break;
  1912.   case Tree_ProcCall:;
  1913.     {
  1914.       register Tree_yProcCall *W_63 = &t->U_1.V_76.ProcCall;
  1915.  
  1916.       CheckExprVar(W_63->Call, dFormals);
  1917.       Check(W_63->Call);
  1918.       Check(W_63->Next);
  1919.       return;
  1920.     }
  1921.     break;
  1922.   case Tree_Condition:;
  1923.     {
  1924.       register Tree_yCondition *W_64 = &t->U_1.V_77.Condition;
  1925.  
  1926.       CheckExprVar(W_64->Expr, dFormals);
  1927.       Check(W_64->Expr);
  1928.       Check(W_64->Next);
  1929.       return;
  1930.     }
  1931.     break;
  1932.   case Tree_Assignment:;
  1933.     {
  1934.       register Tree_yAssignment *W_65 = &t->U_1.V_78.Assignment;
  1935.  
  1936.       if (W_65->Adr->U_1.V_1.Kind == Tree_VarUse) {
  1937.         W_65->Object = Semantics_IdentifyVar(Decls, W_65->Adr->U_1.V_62.VarUse.Name);
  1938.       } else {
  1939.         W_65->Object = Tree_NoTree;
  1940.       }
  1941.       CheckExprVar(W_65->Adr, dFormals);
  1942.       if (W_65->Object != Tree_NoTree) {
  1943.         CheckExprVar(W_65->Expr, W_65->Object);
  1944.       } else {
  1945.         CheckExprVar(W_65->Expr, dFormals);
  1946.       }
  1947.       Check(W_65->Adr);
  1948.       Check(W_65->Expr);
  1949.       Check(W_65->Next);
  1950.       return;
  1951.     }
  1952.     break;
  1953.   case Tree_TargetStmt:;
  1954.     {
  1955.       register Tree_yTargetStmt *W_66 = &t->U_1.V_81.TargetStmt;
  1956.  
  1957.       CheckTargetCode(W_66->Parameters);
  1958.       Sets_MakeSet(&W_66->UsedNames, (LONGCARD)Idents_MaxIdent());
  1959.       ActNames = W_66->UsedNames;
  1960.       Check(W_66->Stmt);
  1961.       W_66->UsedNames = ActNames;
  1962.       Check(W_66->Next);
  1963.       return;
  1964.     }
  1965.     break;
  1966.   case Tree_Statement:;
  1967.   case Tree_Reject:;
  1968.   case Tree_Fail:;
  1969.   case Tree_Nl:;
  1970.   case Tree_WriteStr:;
  1971.     {
  1972.       register Tree_yStatement *W_67 = &t->U_1.V_75.Statement;
  1973.  
  1974.       Check(W_67->Next);
  1975.       return;
  1976.     }
  1977.     break;
  1978.   case Tree_OnePattern:;
  1979.     {
  1980.       register Tree_yOnePattern *W_68 = &t->U_1.V_45.OnePattern;
  1981.  
  1982.       Check(W_68->Pattern);
  1983.       Check(W_68->Next);
  1984.       return;
  1985.     }
  1986.     break;
  1987.   case Tree_OneExpr:;
  1988.   case Tree_NamedExpr:;
  1989.     {
  1990.       register Tree_yOneExpr *W_69 = &t->U_1.V_58.OneExpr;
  1991.  
  1992.       Check(W_69->Expr);
  1993.       Check(W_69->Next);
  1994.       return;
  1995.     }
  1996.     break;
  1997.   case Tree_Decompose:;
  1998.     {
  1999.       register Tree_yDecompose *W_70 = &t->U_1.V_50.Decompose;
  2000.  
  2001.       Check(W_70->Expr);
  2002.       Success = TRUE;
  2003.       Check(W_70->Patterns);
  2004.       return;
  2005.     }
  2006.     break;
  2007.   case Tree_VarDef:;
  2008.     {
  2009.       register Tree_yVarDef *W_71 = &t->U_1.V_51.VarDef;
  2010.  
  2011.       if (W_71->Object != Tree_NoTree) {
  2012.         Success = TRUE;
  2013.       }
  2014.       return;
  2015.     }
  2016.     break;
  2017.   case Tree_NilTest:;
  2018.     {
  2019.       register Tree_yNilTest *W_72 = &t->U_1.V_52.NilTest;
  2020.  
  2021.       Success = TRUE;
  2022.       return;
  2023.     }
  2024.     break;
  2025.   case Tree_Value:;
  2026.     {
  2027.       register Tree_yValue *W_73 = &t->U_1.V_55.Value;
  2028.  
  2029.       Success = TRUE;
  2030.       Check(W_73->Expr);
  2031.       return;
  2032.     }
  2033.     break;
  2034.   case Tree_Compose:;
  2035.     {
  2036.       register Tree_yCompose *W_74 = &t->U_1.V_61.Compose;
  2037.  
  2038.       Check(W_74->Expr);
  2039.       Check(W_74->Exprs);
  2040.       return;
  2041.     }
  2042.     break;
  2043.   case Tree_Call:;
  2044.     {
  2045.       register Tree_yCall *W_75 = &t->U_1.V_65.Call;
  2046.  
  2047.       Check(W_75->Expr);
  2048.       Check(W_75->Exprs);
  2049.       Check(W_75->Patterns);
  2050.       return;
  2051.     }
  2052.     break;
  2053.   case Tree_Binary:;
  2054.     {
  2055.       register Tree_yBinary *W_76 = &t->U_1.V_66.Binary;
  2056.  
  2057.       Check(W_76->Lop);
  2058.       Check(W_76->Rop);
  2059.       return;
  2060.     }
  2061.     break;
  2062.   case Tree_PreOperator:;
  2063.     {
  2064.       register Tree_yPreOperator *W_77 = &t->U_1.V_67.PreOperator;
  2065.  
  2066.       Check(W_77->Expr);
  2067.       return;
  2068.     }
  2069.     break;
  2070.   case Tree_PostOperator:;
  2071.     {
  2072.       register Tree_yPostOperator *W_78 = &t->U_1.V_68.PostOperator;
  2073.  
  2074.       Check(W_78->Expr);
  2075.       return;
  2076.     }
  2077.     break;
  2078.   case Tree_Parents:;
  2079.     {
  2080.       register Tree_yParents *W_79 = &t->U_1.V_70.Parents;
  2081.  
  2082.       Check(W_79->Expr);
  2083.       return;
  2084.     }
  2085.     break;
  2086.   case Tree_Index:;
  2087.     {
  2088.       register Tree_yIndex *W_80 = &t->U_1.V_69.Index;
  2089.  
  2090.       Check(W_80->Expr);
  2091.       Check(W_80->Exprs);
  2092.       return;
  2093.     }
  2094.     break;
  2095.   case Tree_TargetExpr:;
  2096.     {
  2097.       register Tree_yTargetExpr *W_81 = &t->U_1.V_71.TargetExpr;
  2098.  
  2099.       Sets_MakeSet(&W_81->UsedNames, (LONGCARD)Idents_MaxIdent());
  2100.       ActNames = W_81->UsedNames;
  2101.       Check(W_81->Expr);
  2102.       W_81->UsedNames = ActNames;
  2103.       return;
  2104.     }
  2105.     break;
  2106.   case Tree_Ident:;
  2107.     {
  2108.       register Tree_yIdent *W_82 = &t->U_1.V_16.Ident;
  2109.  
  2110.       if (Semantics_IdentifyVar(Decls, W_82->Attribute) == Tree_NoTree) {
  2111.         Sets_Include(&ActNames, (LONGCARD)W_82->Attribute);
  2112.       }
  2113.       Check(W_82->Next);
  2114.       return;
  2115.     }
  2116.     break;
  2117.   case Tree_Any:;
  2118.     {
  2119.       register Tree_yAny *W_83 = &t->U_1.V_18.Any;
  2120.  
  2121.       Check(W_83->Next);
  2122.       return;
  2123.     }
  2124.     break;
  2125.   case Tree_Anys:;
  2126.     {
  2127.       register Tree_yAnys *W_84 = &t->U_1.V_19.Anys;
  2128.  
  2129.       Check(W_84->Next);
  2130.       return;
  2131.     }
  2132.     break;
  2133.   case Tree_Designator:;
  2134.     {
  2135.       register Tree_yDesignator *W_85 = &t->U_1.V_15.Designator;
  2136.  
  2137.       if (Sets_IsElement((LONGCARD)W_85->Selector, &LabelNames)) {
  2138.         W_85->Object = Semantics_IdentifyVar(Decls, W_85->Selector);
  2139.         if (W_85->Object->U_1.V_86.Formal.TypeDesc->U_1.V_1.Kind == Tree_NodeTypes) {
  2140.           ActClass = Semantics_LookupClass(W_85->Object->U_1.V_86.Formal.TypeDesc->U_1.V_89.NodeTypes.TreeName->U_1.V_29.TreeName.Classes, Sets_Minimum(&W_85->Object->U_1.V_86.Formal.TypeDesc->U_1.V_89.NodeTypes.Types));
  2141.           W_85->Type = ActClass->U_1.V_5.Class.Name;
  2142.         } else {
  2143.           Scanner_Error((STRING)"tree-type required", 18L, W_85->Pos);
  2144.         }
  2145.       } else {
  2146.         Scanner_Error((STRING)"label not declared or computed", 30L, W_85->Pos);
  2147.       }
  2148.       Check(W_85->Next);
  2149.       return;
  2150.     }
  2151.     break;
  2152.   default :
  2153.     break;
  2154.   }
  2155. }
  2156.  
  2157. static void CheckTargetCode
  2158. # ifdef __STDC__
  2159. (Tree_tTree t)
  2160. # else
  2161. (t)
  2162. Tree_tTree t;
  2163. # endif
  2164. {
  2165.   struct S_11 yyTempo;
  2166.  
  2167.   if (t == Tree_NoTree) {
  2168.     return;
  2169.   }
  2170.   switch (t->U_1.V_1.Kind) {
  2171.   case Tree_Param:;
  2172.     {
  2173.       register Tree_yParam *W_86 = &t->U_1.V_38.Param;
  2174.  
  2175.       HasLocals = TRUE;
  2176.       ParamName = W_86->Name;
  2177.       IsOutput = FALSE;
  2178.       ProcFormals(W_86->Type);
  2179.       if (Sets_IsElement((LONGCARD)W_86->Name, &LabelNames)) {
  2180.         Scanner_Error((STRING)"label multiply declared or computed", 35L, W_86->Pos);
  2181.       } else {
  2182.         Sets_Include(&LabelNames, (LONGCARD)W_86->Name);
  2183.       }
  2184.       CheckTargetCode(W_86->Next);
  2185.       return;
  2186.     }
  2187.     break;
  2188.   case Tree_ProcCall:;
  2189.     {
  2190.       register Tree_yProcCall *W_87 = &t->U_1.V_76.ProcCall;
  2191.  
  2192.       CheckTargetCode(W_87->Call);
  2193.       CheckTargetCode(W_87->Next);
  2194.       return;
  2195.     }
  2196.     break;
  2197.   case Tree_Condition:;
  2198.     {
  2199.       register Tree_yCondition *W_88 = &t->U_1.V_77.Condition;
  2200.  
  2201.       CheckTargetCode(W_88->Expr);
  2202.       CheckTargetCode(W_88->Next);
  2203.       return;
  2204.     }
  2205.     break;
  2206.   case Tree_Assignment:;
  2207.     {
  2208.       register Tree_yAssignment *W_89 = &t->U_1.V_78.Assignment;
  2209.  
  2210.       CheckTargetCode(W_89->Expr);
  2211.       CheckTargetCode(W_89->Next);
  2212.       return;
  2213.     }
  2214.     break;
  2215.   case Tree_TargetStmt:;
  2216.     {
  2217.       register Tree_yTargetStmt *W_90 = &t->U_1.V_81.TargetStmt;
  2218.  
  2219.       ActNames = W_90->UsedNames;
  2220.       CheckTargetCode(W_90->Stmt);
  2221.       Sets_ReleaseSet(&W_90->UsedNames);
  2222.       CheckTargetCode(W_90->Next);
  2223.       return;
  2224.     }
  2225.     break;
  2226.   case Tree_Statement:;
  2227.   case Tree_Reject:;
  2228.   case Tree_Fail:;
  2229.   case Tree_Nl:;
  2230.   case Tree_WriteStr:;
  2231.     {
  2232.       register Tree_yStatement *W_91 = &t->U_1.V_75.Statement;
  2233.  
  2234.       CheckTargetCode(W_91->Next);
  2235.       return;
  2236.     }
  2237.     break;
  2238.   case Tree_OnePattern:;
  2239.     {
  2240.       register Tree_yOnePattern *W_92 = &t->U_1.V_45.OnePattern;
  2241.  
  2242.       CheckTargetCode(W_92->Pattern);
  2243.       CheckTargetCode(W_92->Next);
  2244.       return;
  2245.     }
  2246.     break;
  2247.   case Tree_OneExpr:;
  2248.   case Tree_NamedExpr:;
  2249.     {
  2250.       register Tree_yOneExpr *W_93 = &t->U_1.V_58.OneExpr;
  2251.  
  2252.       CheckTargetCode(W_93->Expr);
  2253.       CheckTargetCode(W_93->Next);
  2254.       return;
  2255.     }
  2256.     break;
  2257.   case Tree_Decompose:;
  2258.     {
  2259.       register Tree_yDecompose *W_94 = &t->U_1.V_50.Decompose;
  2260.  
  2261.       CheckTargetCode(W_94->Expr);
  2262.       CheckTargetCode(W_94->Patterns);
  2263.       return;
  2264.     }
  2265.     break;
  2266.   case Tree_Value:;
  2267.     {
  2268.       register Tree_yValue *W_95 = &t->U_1.V_55.Value;
  2269.  
  2270.       CheckTargetCode(W_95->Expr);
  2271.       return;
  2272.     }
  2273.     break;
  2274.   case Tree_Compose:;
  2275.     {
  2276.       register Tree_yCompose *W_96 = &t->U_1.V_61.Compose;
  2277.  
  2278.       CheckTargetCode(W_96->Expr);
  2279.       CheckTargetCode(W_96->Exprs);
  2280.       return;
  2281.     }
  2282.     break;
  2283.   case Tree_Call:;
  2284.     {
  2285.       register Tree_yCall *W_97 = &t->U_1.V_65.Call;
  2286.  
  2287.       CheckTargetCode(W_97->Expr);
  2288.       CheckTargetCode(W_97->Exprs);
  2289.       CheckTargetCode(W_97->Patterns);
  2290.       return;
  2291.     }
  2292.     break;
  2293.   case Tree_Binary:;
  2294.     {
  2295.       register Tree_yBinary *W_98 = &t->U_1.V_66.Binary;
  2296.  
  2297.       CheckTargetCode(W_98->Lop);
  2298.       CheckTargetCode(W_98->Rop);
  2299.       return;
  2300.     }
  2301.     break;
  2302.   case Tree_PreOperator:;
  2303.     {
  2304.       register Tree_yPreOperator *W_99 = &t->U_1.V_67.PreOperator;
  2305.  
  2306.       CheckTargetCode(W_99->Expr);
  2307.       return;
  2308.     }
  2309.     break;
  2310.   case Tree_PostOperator:;
  2311.     {
  2312.       register Tree_yPostOperator *W_100 = &t->U_1.V_68.PostOperator;
  2313.  
  2314.       CheckTargetCode(W_100->Expr);
  2315.       return;
  2316.     }
  2317.     break;
  2318.   case Tree_Parents:;
  2319.     {
  2320.       register Tree_yParents *W_101 = &t->U_1.V_70.Parents;
  2321.  
  2322.       CheckTargetCode(W_101->Expr);
  2323.       return;
  2324.     }
  2325.     break;
  2326.   case Tree_Index:;
  2327.     {
  2328.       register Tree_yIndex *W_102 = &t->U_1.V_69.Index;
  2329.  
  2330.       CheckTargetCode(W_102->Expr);
  2331.       CheckTargetCode(W_102->Exprs);
  2332.       return;
  2333.     }
  2334.     break;
  2335.   case Tree_TargetExpr:;
  2336.     {
  2337.       register Tree_yTargetExpr *W_103 = &t->U_1.V_71.TargetExpr;
  2338.  
  2339.       ActNames = W_103->UsedNames;
  2340.       CheckTargetCode(W_103->Expr);
  2341.       Sets_ReleaseSet(&W_103->UsedNames);
  2342.       return;
  2343.     }
  2344.     break;
  2345.   case Tree_Ident:;
  2346.     {
  2347.       register Tree_yIdent *W_104 = &t->U_1.V_16.Ident;
  2348.  
  2349.       if (Sets_IsElement((LONGCARD)W_104->Attribute, &ActNames) && Semantics_IdentifyVar(Decls, W_104->Attribute) != Tree_NoTree) {
  2350.         Scanner_Error((STRING)"label not computed yet", 22L, W_104->Pos);
  2351.       }
  2352.       CheckTargetCode(W_104->Next);
  2353.       return;
  2354.     }
  2355.     break;
  2356.   case Tree_Any:;
  2357.     {
  2358.       register Tree_yAny *W_105 = &t->U_1.V_18.Any;
  2359.  
  2360.       CheckTargetCode(W_105->Next);
  2361.       return;
  2362.     }
  2363.     break;
  2364.   case Tree_Anys:;
  2365.     {
  2366.       register Tree_yAnys *W_106 = &t->U_1.V_19.Anys;
  2367.  
  2368.       CheckTargetCode(W_106->Next);
  2369.       return;
  2370.     }
  2371.     break;
  2372.   case Tree_Designator:;
  2373.     {
  2374.       register Tree_yDesignator *W_107 = &t->U_1.V_15.Designator;
  2375.  
  2376.       CheckTargetCode(W_107->Next);
  2377.       return;
  2378.     }
  2379.     break;
  2380.   default :
  2381.     break;
  2382.   }
  2383. }
  2384.  
  2385. void Semantics_RemoveTreeTypes
  2386. # ifdef __STDC__
  2387. (Tree_tTree t)
  2388. # else
  2389. (t)
  2390. Tree_tTree t;
  2391. # endif
  2392. {
  2393.   struct S_12 yyTempo;
  2394.  
  2395.   if (t == Tree_NoTree) {
  2396.     return;
  2397.   }
  2398.   if (t->U_1.V_1.Kind == Tree_Spec) {
  2399.     {
  2400.       register Tree_ySpec *W_108 = &t->U_1.V_26.Spec;
  2401.  
  2402.       Semantics_RemoveTreeTypes(W_108->TreeNames);
  2403.       return;
  2404.     }
  2405.   }
  2406.   if (t->U_1.V_1.Kind == Tree_TreeName) {
  2407.     {
  2408.       register struct S_13 *W_109 = &yyTempo.U_1.V_1.yyR2;
  2409.  
  2410.       {
  2411.         register Tree_yTreeName *W_110 = &t->U_1.V_29.TreeName;
  2412.  
  2413.         Strings_ArrayToString((STRING)"t", 1L, &W_109->String1);
  2414.         Idents_GetString(W_110->Name, &W_109->String2);
  2415.         Strings_Concatenate(&W_109->String1, &W_109->String2);
  2416.         W_109->i = Idents_MakeIdent(&W_109->String1);
  2417.         if (W_109->i <= Semantics_TypeCount) {
  2418.           Sets_Exclude(&Semantics_TypeNames, (LONGCARD)W_109->i);
  2419.         }
  2420.         Semantics_RemoveTreeTypes(W_110->Next);
  2421.         return;
  2422.       }
  2423.     }
  2424.   }
  2425. }
  2426.  
  2427. static BOOLEAN HasReject
  2428. # ifdef __STDC__
  2429. (Tree_tTree yyP1)
  2430. # else
  2431. (yyP1)
  2432. Tree_tTree yyP1;
  2433. # endif
  2434. {
  2435.   struct S_14 yyTempo;
  2436.  
  2437.   if (yyP1 == Tree_NoTree) {
  2438.     return FALSE;
  2439.   }
  2440.   if (yyP1->U_1.V_1.Kind == Tree_Reject) {
  2441.     return TRUE;
  2442.   }
  2443.   if (Tree_IsType(yyP1, Tree_Statement)) {
  2444.     for (;;) {
  2445.       {
  2446.         register Tree_yStatement *W_111 = &yyP1->U_1.V_75.Statement;
  2447.  
  2448.         if (!HasReject(W_111->Next)) {
  2449.           goto EXIT_3;
  2450.         }
  2451.         return TRUE;
  2452.       }
  2453.     } EXIT_3:;
  2454.   }
  2455.   return FALSE;
  2456. }
  2457.  
  2458. void Semantics_BeginSemantics
  2459. # ifdef __STDC__
  2460. ()
  2461. # else
  2462. ()
  2463. # endif
  2464. {
  2465.   dFormals = Tree_mDummyFormal((Tree_tTree)Tree_NoTree);
  2466.   dFormals->U_1.V_87.DummyFormal.Next = dFormals;
  2467.   nNoFormal = Tree_mNoFormal();
  2468.   Strings_ArrayToString((STRING)".", 1L, &String1);
  2469. }
  2470.  
  2471. void Semantics_CloseSemantics
  2472. # ifdef __STDC__
  2473. ()
  2474. # else
  2475. ()
  2476. # endif
  2477. {
  2478. }
  2479.  
  2480. static void yyExit
  2481. # ifdef __STDC__
  2482. ()
  2483. # else
  2484. ()
  2485. # endif
  2486. {
  2487.   IO_CloseIO();
  2488.   Exit(1L);
  2489. }
  2490.  
  2491. void BEGIN_Semantics()
  2492. {
  2493.   static BOOLEAN has_been_called = FALSE;
  2494.  
  2495.   if (!has_been_called) {
  2496.     has_been_called = TRUE;
  2497.  
  2498.     BEGIN_IO();
  2499.     BEGIN_Tree();
  2500.     BEGIN_Idents();
  2501.     BEGIN_Sets();
  2502.     BEGIN_Tree();
  2503.     BEGIN_System();
  2504.     BEGIN_IO();
  2505.     BEGIN_Tree();
  2506.     BEGIN_General();
  2507.     BEGIN_IO();
  2508.     BEGIN_DynArray();
  2509.     BEGIN_Strings();
  2510.     BEGIN_Idents();
  2511.     BEGIN_Texts();
  2512.     BEGIN_Scanner();
  2513.     BEGIN_Positions();
  2514.     BEGIN_Sets();
  2515.     BEGIN_Tree();
  2516.  
  2517.     Semantics_yyf = IO_StdOutput;
  2518.     Semantics_Exit = yyExit;
  2519.     Semantics_BeginSemantics();
  2520.   }
  2521. }
  2522.